Hi Ricard,

Ricard Pillosu wrote:

Hi all,

Just reading the sqlite-user mailing list I found here

http://www.mail-archive.com/sqlite-users@sqlite.org/msg01521.html

that there is a way to dump from memory databases to file databases. What we are trying in our database is to ATTACH a read-only database and make changes to it in MEMORY. We don't want to save the changes, just be able to make updates to same rows.

Yes, I can do a schema like:

  ATTACH 'abc.db' AS external;
  BEGIN;
  DELETE FROM xyz;
  INSERT INTO xyz SELECT * FROM external.xyz;
  ...
  COMMIT;
  DETACH external;

But the "abc.db" is usually modified, and is a mess to have to change the code (+recompile) for every table added
or changed. I just want to create an exact copy of it in memory, do updates and some selects, and then discard changes. Something like "ATTACH INMEMORY 'file.db' AS external"


Do you think is there a way clean way to do it?

Sorry to be glib, but I am not near my SQLite installation at the moment...

Try a SELECT * FROM sqlite_master;

it should give you some ideas. Specifically, look at the statements that were used to create the tables. You might be able to parse them to extract the table structure dynamically. Otherwise, try some of the PRAGMAs described on the SQLite language page on the website.

HTH

Ulrik P.



Reply via email to