[Assorted-commits] SF.net SVN: assorted:[1422] sandbox/trunk/src/py/sqlitetest.py
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-05-18 16:59:23
|
Revision: 1422 http://assorted.svn.sourceforge.net/assorted/?rev=1422&view=rev Author: yangzhang Date: 2009-05-18 16:59:10 +0000 (Mon, 18 May 2009) Log Message: ----------- added simple demo of isolation levels in sqlite Added Paths: ----------- sandbox/trunk/src/py/sqlitetest.py Added: sandbox/trunk/src/py/sqlitetest.py =================================================================== --- sandbox/trunk/src/py/sqlitetest.py (rev 0) +++ sandbox/trunk/src/py/sqlitetest.py 2009-05-18 16:59:10 UTC (rev 1422) @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +import sqlite3 + +conn = sqlite3.connect('/tmp/db') +conn.text_factory = bytes +conn.execute('CREATE TABLE shelf (key INTEGER NOT NULL, value INTEGER NOT NULL)') +for i in xrange(3): + conn.execute('INSERT INTO shelf (key, value) VALUES (?,?)', (i, i)) +conn.commit() + +# This will loop forever. +if 0: + for i, in conn.cursor().execute('SELECT key FROM shelf ORDER BY ROWID'): + conn.execute('REPLACE INTO shelf (key, value) VALUES (?,?)', (i, i)) + conn.commit() + print i +else: + conn2 = sqlite3.connect('/tmp/db') + conn2.text_factory = bytes + for i, in conn2.execute('SELECT key FROM shelf ORDER BY ROWID'): + conn.execute('REPLACE INTO shelf (key, value) VALUES (?,?)', (i, i)) + conn.commit() + print i Property changes on: sandbox/trunk/src/py/sqlitetest.py ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |