in-memory db? gadfly?

Peter Hansen peter at engcorp.com
Thu Sep 22 17:34:52 EDT 2005


chris wrote:
> I'm looking for a completely in-memory sql db.  I have seen gadfly, but
> its startup method seems to require a directory for the on-disk file
> storage.  I have a script and I want to create a database/tables in the
> script, insert some data (not much), and execute some queries, all
> in-memory.  Don't need to persist anything.  Possible, or am I just
> talking crazy here?

I believe SQLite will do this easily, if you use a connection name of 
":memory:" instead of a file name.

Wrapped with either of:

  - Gerhard Häring's pysqlite (http://initd.org/tracker/pysqlite)

  - Roger Binns' APSW (http://www.rogerbinns.com/apsw.html)

I believe the primary distinction is that pysqlite is DB-API 2.0 
compliant, while APSW is a "thin" wrapper that may or may not feel more 
comfortable for you, and which provides access to more of SQLite's 
features.

(Both appear to have been around roughly the same length of time, though 
pysqlite seems better known.)

-Peter



More information about the Python-list mailing list