diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-05-10 15:56:31 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-05-10 15:56:31 +0000 |
| commit | 48648eedda50a84f5518ac2055286e1fde22fa00 (patch) | |
| tree | 8b80e4935f2df811d1ef510e179a1e6c38d77b57 /lib/sqlalchemy/engine | |
| parent | 98207edf309c58198b6b1700776fc415a6bcac19 (diff) | |
| download | sqlalchemy-48648eedda50a84f5518ac2055286e1fde22fa00.tar.gz | |
propigated detach() and invalidate() methods to Connection.
Diffstat (limited to 'lib/sqlalchemy/engine')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index b3ba657a8..1dfe82934 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -427,6 +427,30 @@ class Connection(Connectable): """contextual_connect() is implemented to return self so that an incoming Engine or Connection object can be treated similarly.""" return self + def invalidate(self): + """invalidate the underying DBAPI connection and immediately close this Connection. + + The underlying DBAPI connection is literally closed (if possible), and is discarded. + Its source connection pool will typically create a new connection to replace it, once + requested. + """ + + self.__connection.invalidate() + self.__connection = None + + def detach(self): + """detach the underlying DBAPI connection from its connection pool. + + This Connection instance will remain useable. When closed, the + DBAPI connection will be literally closed and not returned to its pool. + The pool will typically create a new connection to replace it, once requested. + + This method can be used to insulate the rest of an application from a modified + state on a connection (such as a transaction isolation level or similar). + """ + + self.__connection.detach() + def begin(self): if self.__transaction is None: self.__transaction = self._create_transaction(None) |
