diff options
Diffstat (limited to 'lib/sqlalchemy/engine')
| -rw-r--r-- | lib/sqlalchemy/engine/__init__.py | 10 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/threadlocal.py | 12 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/__init__.py b/lib/sqlalchemy/engine/__init__.py index aebf35436..e33dff53b 100644 --- a/lib/sqlalchemy/engine/__init__.py +++ b/lib/sqlalchemy/engine/__init__.py @@ -175,6 +175,16 @@ def create_engine(*args, **kwargs): be applied to all connections. See :meth:`~sqlalchemy.engine.base.Connection.execution_options` + :param implicit_returning=True: When ``False``, the RETURNING + feature of the database, if available, will not be used + to fetch newly generated primary key values. This applies + to those backends which support RETURNING or a compatible + construct, including Postgresql, Firebird, Oracle, Microsoft + SQL Server. The default behavior is to use a compatible RETURNING + construct when a single-row INSERT statement is emitted with no + existing returning() clause in order to fetch newly generated + primary key values. + :param label_length=None: optional integer value which limits the size of dynamically generated column labels to that many characters. If less than 6, labels are generated as diff --git a/lib/sqlalchemy/engine/threadlocal.py b/lib/sqlalchemy/engine/threadlocal.py index 2ce0922bf..d4d0488a9 100644 --- a/lib/sqlalchemy/engine/threadlocal.py +++ b/lib/sqlalchemy/engine/threadlocal.py @@ -71,16 +71,28 @@ class TLEngine(base.Engine): if not hasattr(self._connections, 'trans'): self._connections.trans = [] self._connections.trans.append(self.contextual_connect().begin_twophase(xid=xid)) + return self def begin_nested(self): if not hasattr(self._connections, 'trans'): self._connections.trans = [] self._connections.trans.append(self.contextual_connect().begin_nested()) + return self def begin(self): if not hasattr(self._connections, 'trans'): self._connections.trans = [] self._connections.trans.append(self.contextual_connect().begin()) + return self + + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + if type is None: + self.commit() + else: + self.rollback() def prepare(self): if not hasattr(self._connections, 'trans') or \ |
