in Ram database?
William Trenker
wtrenker at shaw.ca
Fri Sep 5 16:30:58 EDT 2003
More information about the Python-list mailing list
Fri Sep 5 16:30:58 EDT 2003
- Previous message (by thread): in Ram database?
- Next message (by thread): in Ram database?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 04 Sep 2003 19:14:05 -0700 "John D." <lists at webcrunchers.com> wrote regarding in Ram database?: > Does anyone know if there is an "in-ram" dictionary based database > for Python. This may not be quite what you want, but the SQLite embedded SQL engine has an in-memory option. You would access SQLite using the PySQLite wrapper which is DB-API-2 compliant. Here are the links: http://sqlite.org (download the latest version 2.8.6) http://pysqlite.sourceforge.net Cheers, Bill Here is a simple example: import sqlite #module name exposed by the PySQLite wrapper conn = sqlite.connect(db=':memory:') #special connect string to open an in-memory db cursor = conn.cursor() #standard DB-API-2 from this point cursor.execute('create table test (a varchar, b int);') cursor.execute('commit;') #end PySQLite implicit transaction cursor.execute('begin transaction;') #wrap the inserts in an explicit transaction for speed for i in range(0,10000): cursor.execute('insert into test (a,b) values (%s,%i);'%(str(i),i)) cursor.execute('commit;') cursor.execute('select sum(b) from test;') print cursor.fetchall()[0][0]
- Previous message (by thread): in Ram database?
- Next message (by thread): in Ram database?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list