Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
sqlite3.test.transactions.TransactionTests Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def CheckDMLdoesAutoCommitBefore
def CheckInsertStartsTransaction
def CheckUpdateStartsTransaction
def CheckDeleteStartsTransaction
def CheckReplaceStartsTransaction
def CheckToggleAutoCommit
def CheckRaiseTimeout
def CheckLocking
def CheckRollbackCursorConsistency

Public Attributes

 con1
 cur1
 con2
 cur2

Detailed Description

Definition at line 30 of file transactions.py.


Member Function Documentation

Definition at line 79 of file transactions.py.

00079 
00080     def CheckDeleteStartsTransaction(self):
00081         self.cur1.execute("create table test(i)")
00082         self.cur1.execute("insert into test(i) values (5)")
00083         self.con1.commit()
00084         self.cur1.execute("delete from test")
00085         self.cur2.execute("select i from test")
00086         res = self.cur2.fetchall()
00087         self.assertEqual(len(res), 1)

Here is the call graph for this function:

Definition at line 55 of file transactions.py.

00055 
00056     def CheckDMLdoesAutoCommitBefore(self):
00057         self.cur1.execute("create table test(i)")
00058         self.cur1.execute("insert into test(i) values (5)")
00059         self.cur1.execute("create table test2(j)")
00060         self.cur2.execute("select i from test")
00061         res = self.cur2.fetchall()
00062         self.assertEqual(len(res), 1)

Here is the call graph for this function:

Definition at line 63 of file transactions.py.

00063 
00064     def CheckInsertStartsTransaction(self):
00065         self.cur1.execute("create table test(i)")
00066         self.cur1.execute("insert into test(i) values (5)")
00067         self.cur2.execute("select i from test")
00068         res = self.cur2.fetchall()
00069         self.assertEqual(len(res), 0)

Here is the call graph for this function:

This tests the improved concurrency with pysqlite 2.3.4. You needed
to roll back con2 before you could commit con1.

Definition at line 129 of file transactions.py.

00129 
00130     def CheckLocking(self):
00131         """
00132         This tests the improved concurrency with pysqlite 2.3.4. You needed
00133         to roll back con2 before you could commit con1.
00134         """
00135         if sqlite.sqlite_version_info < (3, 2, 2):
00136             # This will fail (hang) on earlier versions of sqlite.
00137             # Determine exact version it was fixed. 3.2.1 hangs.
00138             return
00139         self.cur1.execute("create table test(i)")
00140         self.cur1.execute("insert into test(i) values (5)")
00141         try:
00142             self.cur2.execute("insert into test(i) values (5)")
00143             self.fail("should have raised an OperationalError")
00144         except sqlite.OperationalError:
00145             pass
00146         except:
00147             self.fail("should have raised an OperationalError")
00148         # NO self.con2.rollback() HERE!!!
00149         self.con1.commit()

Here is the call graph for this function:

Definition at line 114 of file transactions.py.

00114 
00115     def CheckRaiseTimeout(self):
00116         if sqlite.sqlite_version_info < (3, 2, 2):
00117             # This will fail (hang) on earlier versions of sqlite.
00118             # Determine exact version it was fixed. 3.2.1 hangs.
00119             return
00120         self.cur1.execute("create table test(i)")
00121         self.cur1.execute("insert into test(i) values (5)")
00122         try:
00123             self.cur2.execute("insert into test(i) values (5)")
00124             self.fail("should have raised an OperationalError")
00125         except sqlite.OperationalError:
00126             pass
00127         except:
00128             self.fail("should have raised an OperationalError")

Here is the call graph for this function:

Definition at line 88 of file transactions.py.

00088 
00089     def CheckReplaceStartsTransaction(self):
00090         self.cur1.execute("create table test(i)")
00091         self.cur1.execute("insert into test(i) values (5)")
00092         self.con1.commit()
00093         self.cur1.execute("replace into test(i) values (6)")
00094         self.cur2.execute("select i from test")
00095         res = self.cur2.fetchall()
00096         self.assertEqual(len(res), 1)
00097         self.assertEqual(res[0][0], 5)

Here is the call graph for this function:

Checks if cursors on the connection are set into a "reset" state
when a rollback is done on the connection.

Definition at line 150 of file transactions.py.

00150 
00151     def CheckRollbackCursorConsistency(self):
00152         """
00153         Checks if cursors on the connection are set into a "reset" state
00154         when a rollback is done on the connection.
00155         """
00156         con = sqlite.connect(":memory:")
00157         cur = con.cursor()
00158         cur.execute("create table test(x)")
00159         cur.execute("insert into test(x) values (5)")
00160         cur.execute("select 1 union select 2 union select 3")
00161 
00162         con.rollback()
00163         try:
00164             cur.fetchall()
00165             self.fail("InterfaceError should have been raised")
00166         except sqlite.InterfaceError as e:
00167             pass
00168         except:
00169             self.fail("InterfaceError should have been raised")

Here is the call graph for this function:

Definition at line 98 of file transactions.py.

00098 
00099     def CheckToggleAutoCommit(self):
00100         self.cur1.execute("create table test(i)")
00101         self.cur1.execute("insert into test(i) values (5)")
00102         self.con1.isolation_level = None
00103         self.assertEqual(self.con1.isolation_level, None)
00104         self.cur2.execute("select i from test")
00105         res = self.cur2.fetchall()
00106         self.assertEqual(len(res), 1)
00107 
00108         self.con1.isolation_level = "DEFERRED"
00109         self.assertEqual(self.con1.isolation_level , "DEFERRED")
00110         self.cur1.execute("insert into test(i) values (5)")
00111         self.cur2.execute("select i from test")
00112         res = self.cur2.fetchall()
00113         self.assertEqual(len(res), 1)

Here is the call graph for this function:

Definition at line 70 of file transactions.py.

00070 
00071     def CheckUpdateStartsTransaction(self):
00072         self.cur1.execute("create table test(i)")
00073         self.cur1.execute("insert into test(i) values (5)")
00074         self.con1.commit()
00075         self.cur1.execute("update test set i=6")
00076         self.cur2.execute("select i from test")
00077         res = self.cur2.fetchone()[0]
00078         self.assertEqual(res, 5)

Here is the call graph for this function:

Definition at line 31 of file transactions.py.

00031 
00032     def setUp(self):
00033         try:
00034             os.remove(get_db_path())
00035         except OSError:
00036             pass
00037 
00038         self.con1 = sqlite.connect(get_db_path(), timeout=0.1)
00039         self.cur1 = self.con1.cursor()
00040 
00041         self.con2 = sqlite.connect(get_db_path(), timeout=0.1)
00042         self.cur2 = self.con2.cursor()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 43 of file transactions.py.

00043 
00044     def tearDown(self):
00045         self.cur1.close()
00046         self.con1.close()
00047 
00048         self.cur2.close()
00049         self.con2.close()
00050 
00051         try:
00052             os.unlink(get_db_path())
00053         except OSError:
00054             pass

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 37 of file transactions.py.

Definition at line 40 of file transactions.py.

Definition at line 38 of file transactions.py.

Definition at line 41 of file transactions.py.


The documentation for this class was generated from the following file: