Page 1 of 1

How to create a database in memory?

Posted: 06.02.2008, 12:01
by pol
Hi!

It should be possible to create a SQLite database in memory, on the fly, create and populate tables and do sql operations on them. Other components (DISqlite) can do that.
Any ideas how this could be done using Zeos?

Regards,
Rüdiger

Posted: 03.03.2008, 20:56
by TheBlackSheep
Hi Rüdiger

that's easy, drop a zeos TZConnection component on a form or datamodule and set the database to ":memory:" (without the quotes " " of course but both colons ( : ) at each end are important. Set the "Connected" property to true and just point the TZQuery/TZReadOnlyQuery/TZTable components you add to this connection. that's it really.

If you Disconnect (or set the Active state to false) on the TZConnection, you'll effectively drop any database/tables you've created etc.

It definitely does work with Zeos :-)

Chrs

Posted: 05.03.2008, 09:01
by cipto_kh
That's feature is only happen in SQLite?

Posted: 05.03.2008, 11:40
by pol
Hi Chris,

Thanky you. What I did wrong was writing :MEMORY instead of :memory:. Who would expect that?
Now it is working fine :-)

Rüdiger

Posted: 05.05.2008, 09:06
by DucatiDesmo
I find this really interesting!
Sorry for this newbie question, (newbie of sqlite and zeos components!)

...is it possible to store the memory database to a file?

thanks,
Filippo Forlani

Posted: 02.06.2008, 14:36
by aducom
Yes, attach a real db with table and use simple sql to copy the data. You cannot just 'save'. Then you should consider using a real table in the first place