File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
src/springpython/database Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -92,20 +92,21 @@ def count_type(self):
92
92
return types .LongType
93
93
94
94
class Sqlite3ConnectionFactory (ConnectionFactory ):
95
- def __init__ (self , db = None ):
95
+ def __init__ (self , db = None , check_same_thread = True ):
96
96
ConnectionFactory .__init__ (self , [types .TupleType ])
97
97
self .db = db
98
+ self .check_same_thread = check_same_thread
98
99
self .using_sqlite3 = True
99
100
100
101
def connect (self ):
101
102
"""The import statement is delayed so the library is loaded ONLY if this factory is really used."""
102
103
try :
103
104
import sqlite3
104
- return sqlite3 .connect (self .db )
105
+ return sqlite3 .connect (self .db , check_same_thread = self . check_same_thread )
105
106
except :
106
107
import sqlite
107
108
self .using_sqlite3 = False
108
- return sqlite .connect (self .db )
109
+ return sqlite .connect (self .db , check_same_thread = self . check_same_thread )
109
110
110
111
def in_transaction (self ):
111
112
return True
Original file line number Diff line number Diff line change @@ -62,6 +62,14 @@ def testConnectingToSqlite(self):
62
62
63
63
del (sys .modules ["sqlite3" ])
64
64
65
+ def testConnectingToSqliteWithSpecialCheck (self ):
66
+ sys .modules ["sqlite3" ] = self .mock ()
67
+ sys .modules ["sqlite3" ].expects (once ()).method ("connect" )
68
+
69
+ connection_factory = factory .Sqlite3ConnectionFactory (db = "/tmp/foobar" , check_same_thread = False )
70
+ connection = connection_factory .connect ()
71
+
72
+ del (sys .modules ["sqlite3" ])
65
73
66
74
def testConnectingToOracle (self ):
67
75
sys .modules ["cx_Oracle" ] = self .mock ()
You can’t perform that action at this time.
0 commit comments