0.1.5
- fixed attributes bug where if an object is committed, its lazy-loaded list got
blown away if it hadnt been loaded
+- added unique_connection() method to engine, connection pool to return a connection
+that is not part of the thread-local context or any current transaction
0.1.4
- create_engine() now uses genericized parameters; host/hostname, db/dbname/database,
"""returns a managed DBAPI connection from this SQLEngine's connection pool."""
return self._pool.connect()
+ def unique_connection(self):
+ """returns a DBAPI connection from this SQLEngine's connection pool that is distinct from the current thread's connection."""
+ return self._pool.unique_connection()
+
def multi_transaction(self, tables, func):
"""provides a transaction boundary across tables which may be in multiple databases.
If you have three tables, and a function that operates upon them, providing the tables as a
self._use_threadlocal = use_threadlocal
self._echo = echo
self._logger = logger or util.Logger(origin='pool')
-
+
+ def unique_connection(self):
+ return ConnectionFairy(self)
+
def connect(self):
if not self._use_threadlocal:
return ConnectionFairy(self)
self.logger.write(msg)
class ConnectionFairy(object):
- def __init__(self, pool):
+ def __init__(self, pool, connection=None):
self.pool = pool
- try:
- self.connection = pool.get()
- except:
- self.connection = None
- self.pool.return_invalid()
- raise
+ if connection is not None:
+ self.connection = connection
+ else:
+ try:
+ self.connection = pool.get()
+ except:
+ self.connection = None
+ self.pool.return_invalid()
+ raise
def cursor(self):
return CursorFairy(self, self.connection.cursor())
def __getattr__(self, key):
def status(self):
return "SingletonThreadPool size: %d" % len(self._conns)
+ def unique_connection(self):
+ return ConnectionFairy(self, self._creator())
+
def do_return_conn(self, conn):
pass
def do_return_invalid(self):