views:

104

answers:

3

I'm doing some queries in Python on a large database to get some stats out of the database. I want these stats to be in-memory so other programs can use them without going to a database.

I was thinking of how to structure them, and after trying to set up some complicated nested dictionaries, I realized that a good representation would be an SQL table. I don't want to store the data back into the persistent database, though. Are there any in-memory implementations of an SQL database that supports querying the data with SQL syntax?

A: 

I guess, SQLite3 will be the best option then.

If possible, take a look at memcached. (for key-value pair, lighting fast!)

UPDATE 1:

HSQLDB for SQL Like tables. (no python support)

zengr
+6  A: 

SQLite3 might work. The Python interface does support the in-memory implementation that the SQLite3 C API offers.

From the spec:

You can also supply the special name :memory: to create a database in RAM.

Its also relatively cheap with transactions, depending on what you are doing.

Tim Post
A: 

You could possibly use a database like SQLite. It's not strictly speaking in memory, but it is fairly light and would be completely separate from your main database.

Matthew Vines
SQLite3 databases can be opened in memory only. Its one of the great perks of SQLite3.
Tim Post
That's good to know, thanks for the tip.
Matthew Vines