]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added StaticPool, stores just one connection.
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 9 Jun 2007 20:59:59 +0000 (20:59 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 9 Jun 2007 20:59:59 +0000 (20:59 +0000)
lib/sqlalchemy/pool.py

index 8915b8098d9b062d014bc85db76029e4751d5876..a77e979abd6c73600d8fa3892bc78df7e29ecee3 100644 (file)
@@ -536,6 +536,31 @@ class NullPool(Pool):
     def do_get(self):
         return self.create_connection()
 
+class StaticPool(Pool):
+    """A Pool implementation which stores exactly one connection that is 
+    returned for all requests."""
+
+    def __init__(self, creator, **params):
+        Pool.__init__(self, creator, **params)
+        self._conn = creator()
+        self.connection = _ConnectionRecord(self)
+
+    def status(self):
+        return "StaticPool"
+
+    def create_connection(self):
+        return self._conn
+
+    def do_return_conn(self, conn):
+        pass
+
+    def do_return_invalid(self, conn):
+        pass
+
+    def do_get(self):
+        return self.connection
+    
+    
 class AssertionPool(Pool):
     """A Pool implementation that allows at most one checked out
     connection at a time.