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):
9292 return types .LongType
9393
9494class Sqlite3ConnectionFactory (ConnectionFactory ):
95- def __init__ (self , db = None ):
95+ def __init__ (self , db = None , check_same_thread = True ):
9696 ConnectionFactory .__init__ (self , [types .TupleType ])
9797 self .db = db
98+ self .check_same_thread = check_same_thread
9899 self .using_sqlite3 = True
99100
100101 def connect (self ):
101102 """The import statement is delayed so the library is loaded ONLY if this factory is really used."""
102103 try :
103104 import sqlite3
104- return sqlite3 .connect (self .db )
105+ return sqlite3 .connect (self .db , check_same_thread = self . check_same_thread )
105106 except :
106107 import sqlite
107108 self .using_sqlite3 = False
108- return sqlite .connect (self .db )
109+ return sqlite .connect (self .db , check_same_thread = self . check_same_thread )
109110
110111 def in_transaction (self ):
111112 return True
Original file line number Diff line number Diff line change @@ -62,6 +62,14 @@ def testConnectingToSqlite(self):
6262
6363 del (sys .modules ["sqlite3" ])
6464
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" ])
6573
6674 def testConnectingToOracle (self ):
6775 sys .modules ["cx_Oracle" ] = self .mock ()
You can’t perform that action at this time.
0 commit comments