You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following script should print "My precious data is here.", but it raises an exception instead...
I think pysqlite should not implicitly mess with transactions in "autocommit" mode (when isolation_level = None).
My proposed patch corrects the problem.
BEGIN
import pysqlite2.dbapi2 as sqlite3
import sqlite3
con = sqlite3.connect(':memory:')
con.isolation_level = None
cur = con.cursor()
cur.execute('create table test(t text)')
cur.execute('insert into test(t) values(?)', ('My precious data is here.',))
after the next command, inTransaction will be 1,
because of the following line in cursor.c, (line 762):
self->connection->inTransaction =
!sqlite3_get_autocommit(self->connection->db);
cur.execute('begin')
cur.execute('drop table test')
Now issue an arbitrary dummy command using executescript.
From ikar...@gmail.com on May 02, 2013 17:16:47
The following script should print "My precious data is here.", but it raises an exception instead...
I think pysqlite should not implicitly mess with transactions in "autocommit" mode (when isolation_level = None).
My proposed patch corrects the problem.
BEGIN
import pysqlite2.dbapi2 as sqlite3
import sqlite3
con = sqlite3.connect(':memory:')
con.isolation_level = None
cur = con.cursor()
cur.execute('create table test(t text)')
cur.execute('insert into test(t) values(?)', ('My precious data is here.',))
after the next command, inTransaction will be 1,
because of the following line in cursor.c, (line 762):
self->connection->inTransaction =
!sqlite3_get_autocommit(self->connection->db);
cur.execute('begin')
cur.execute('drop table test')
Now issue an arbitrary dummy command using executescript.
executescript implicitly calls pysqlite_connection_commit.
Since inTransaction == 1, this will actually commit the transaction.
cur.executescript('select 2+3')
There is no way to roll back.
cur.execute('rollback')
for x in cur.execute('select t from test'):
print(x[0])
cur.close()
con.close()
END
Attachment: patch.diff test.py
Original issue: http://code.google.com/p/pysqlite/issues/detail?id=59
The text was updated successfully, but these errors were encountered: