[issue7572] Strabge issue : cursor.commit() with sqlite

lakshmipathi report at bugs.python.org
Tue Dec 29 11:43:07 CET 2009

lakshmipathi <lakshmipathi.g at gmail.com> added the comment:

ok..let me put this question ,in different manner.
Here is my code (example2)
import sqlite3
def loopy():
	return 'GNU'
#get connection object 
conn = sqlite3.connect("/tmp/example2")
#get curson obj. and invoke execute
cur = conn.cursor()
cur.execute('''create table stk (txt text)''')
#insert a single record
cur.execute("insert into stk values (?)",t)
#I have close it without committing. -So my record length == 0
#But when  i open again new cursor cur1
cur1.execute("select * from stk")
row = cur1.fetchall()
# i expect this assert to pass - since there is no record 
assert len(row) < 1

I used sqlite3 /tmp/example2 and select * from stk returned zero records
as expected.
So commit refers to committing to Database not with in the program.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list