Hi!

On Wed, Oct 16, 2013 at 10:58:24PM +0100, "Maciej (Matchek) Blizi??ski" 
<mac...@opencsw.org> wrote:
> - there already is special handling for in-memory databases, so
> maybe add a little more special handling for them; for example free
> the memory on close().

   The patch to test is attached.

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            p...@phdru.name
           Programmers don't die, they just GOSUB without RETURN.
Index: sqlobject/sqlite/sqliteconnection.py
===================================================================
--- sqlobject/sqlite/sqliteconnection.py	(revision 4673)
+++ sqlobject/sqlite/sqliteconnection.py	(working copy)
@@ -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:
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to