Author: phd
Date: Sun Dec 8 08:57:03 2013
New Revision: 4677
Log:
Merge revision 4676 from branch 1.5: SQLiteConnection.close()
now closes and reopens a connection to in-memory database.
Modified:
SQLObject/trunk/docs/News.txt
SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
SQLObject/trunk/sqlobject/tests/dbtest.py
SQLObject/trunk/sqlobject/tests/test_sqlite.py
Modified: SQLObject/trunk/docs/News.txt
==============================================================================
--- SQLObject/trunk/docs/News.txt Sun Dec 8 08:54:13 2013 (r4676)
+++ SQLObject/trunk/docs/News.txt Sun Dec 8 08:57:03 2013 (r4677)
@@ -16,6 +16,12 @@
* Python 2.4 is no longer supported. The minimal supported version is
Python 2.5.
+SQLObject 1.5.1
+===============
+
+* SQLiteConnection.close() now closes and reopens a connection
+ to in-memory database.
+
SQLObject 1.5.0
===============
Modified: SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
==============================================================================
--- SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py Sun Dec 8 08:54:13 2013 (r4676)
+++ SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py Sun Dec 8 08:57:03 2013 (r4677)
@@ -89,11 +89,7 @@
self._threadPool = {}
self._threadOrigination = {}
if self._memory:
- self._memoryConn = sqlite.connect(
- self.filename, **self._connOptions)
- # Convert text data from SQLite to str, not unicode -
- # SQLObject converts it to unicode itself.
- self._memoryConn.text_factory = str
+ self.makeMemoryConnection()
@classmethod
def _connectionFromParams(cls, user, password, host, port, path, args):
@@ -184,6 +180,13 @@
return
conn.isolation_level = level
+ def makeMemoryConnection(self):
+ self._memoryConn = self.module.connect(
+ self.filename, **self._connOptions)
+ # Convert text data from SQLite to str, not unicode -
+ # SQLObject converts it to unicode itself.
+ self._memoryConn.text_factory = str
+
def makeConnection(self):
if self._memory:
return self._memoryConn
@@ -194,6 +197,9 @@
def close(self):
DBAPI.close(self)
self._threadPool = {}
+ if self._memory:
+ self._memoryConn.close()
+ self.makeMemoryConnection()
def _executeRetry(self, conn, cursor, query):
if self.debug:
Modified: SQLObject/trunk/sqlobject/tests/dbtest.py
==============================================================================
--- SQLObject/trunk/sqlobject/tests/dbtest.py Sun Dec 8 08:54:13 2013 (r4676)
+++ SQLObject/trunk/sqlobject/tests/dbtest.py Sun Dec 8 08:57:03 2013 (r4677)
@@ -41,6 +41,7 @@
'-emptyTable': 'mssql',
'-limitSelect' : 'mssql',
'+schema' : 'postgres',
+ '+memorydb': 'sqlite',
}
Modified: SQLObject/trunk/sqlobject/tests/test_sqlite.py
==============================================================================
--- SQLObject/trunk/sqlobject/tests/test_sqlite.py Sun Dec 8 08:54:13 2013 (r4676)
+++ SQLObject/trunk/sqlobject/tests/test_sqlite.py Sun Dec 8 08:57:03 2013 (r4677)
@@ -104,3 +104,16 @@
test = TestSO1(name=None, passwd='')
assert test.name is None
assert test.passwd == ''
+
+def test_memorydb():
+ if not supports("memorydb"):
+ return
+ connection = getConnection()
+ if connection.dbName != "sqlite":
+ return
+ if not connection._memory:
+ return
+ setupClass(TestSO1)
+ connection.close() # create a new connection to an in-memory database
+ TestSO1.setConnection(connection)
+ TestSO1.createTable()
|