diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-30 19:48:48 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-30 19:48:48 -0400 |
| commit | 868da0c281904aa66cde9eeae32a740acab108fe (patch) | |
| tree | 41078107eb26c4dbeff3342e608c4e3d0d089c8b /lib/sqlalchemy/dialects/firebird/fdb.py | |
| parent | b38a76cd1d47cd6b8f1abef30ad7c3aeaa27d537 (diff) | |
| download | sqlalchemy-868da0c281904aa66cde9eeae32a740acab108fe.tar.gz | |
Added new flag ``retaining=False`` to the kinterbasdb and fdb dialects.
This controls the value of the ``retaining`` flag sent to the
``commit()`` and ``rollback()`` methods of the DBAPI connection.
Defaults to False. Also in 0.8.2, where it defaults to True.
[ticket:2763]
Diffstat (limited to 'lib/sqlalchemy/dialects/firebird/fdb.py')
| -rw-r--r-- | lib/sqlalchemy/dialects/firebird/fdb.py | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/firebird/fdb.py b/lib/sqlalchemy/dialects/firebird/fdb.py index 8d0bd3d78..36b424d49 100644 --- a/lib/sqlalchemy/dialects/firebird/fdb.py +++ b/lib/sqlalchemy/dialects/firebird/fdb.py @@ -19,7 +19,49 @@ under the ``firebird://`` URL space, as ``fdb`` is now the official Python driver for Firebird. -The dialect currently accepts the same arguments as the Kinterbasdb driver. +Arguments +---------- + +The ``fdb`` dialect is based on the :mod:`sqlalchemy.dialects.firebird.kinterbasdb` +dialect, however does not accept every argument that Kinterbasdb does. + +* ``enable_rowcount`` - True by default, setting this to False disables + the usage of "cursor.rowcount" with the + Kinterbasdb dialect, which SQLAlchemy ordinarily calls upon automatically + after any UPDATE or DELETE statement. When disabled, SQLAlchemy's + ResultProxy will return -1 for result.rowcount. The rationale here is + that Kinterbasdb requires a second round trip to the database when + .rowcount is called - since SQLA's resultproxy automatically closes + the cursor after a non-result-returning statement, rowcount must be + called, if at all, before the result object is returned. Additionally, + cursor.rowcount may not return correct results with older versions + of Firebird, and setting this flag to False will also cause the + SQLAlchemy ORM to ignore its usage. The behavior can also be controlled on a + per-execution basis using the ``enable_rowcount`` option with + :meth:`.Connection.execution_options`:: + + conn = engine.connect().execution_options(enable_rowcount=True) + r = conn.execute(stmt) + print r.rowcount + +* ``retaining`` - False by default. Setting this to True will pass the + ``retaining=True`` keyword argument to the ``.commit()`` and ``.rollback()`` + methods of the DBAPI connection, which can improve performance in some + situations, but apparently with significant caveats. + Please read the fdb and/or kinterbasdb DBAPI documentation in order to + understand the implications of this flag. + + .. versionadded:: 0.8.2 - ``retaining`` keyword argument specifying + transaction retaining behavior - in 0.8 it defaults to ``True`` + for backwards compatibility. + + .. versionchanged:: 0.9.0 - the ``retaining`` flag defaults to ``False``. + In 0.8 it defaulted to ``True``. + + .. seealso:: + + http://pythonhosted.org/fdb/usage-guide.html#retaining-transactions - information + on the "retaining" flag. """ @@ -29,6 +71,12 @@ from ... import util class FBDialect_fdb(FBDialect_kinterbasdb): + def __init__(self, enable_rowcount=True, + retaining=False, **kwargs): + super(FBDialect_fdb, self).__init__( + enable_rowcount=enable_rowcount, + retaining=retaining, **kwargs) + @classmethod def dbapi(cls): return __import__('fdb') |
