diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-24 10:22:39 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-24 10:22:39 -0400 |
commit | 87d7076b49ec52d6f890d1dc56f61ea2eb83f3a6 (patch) | |
tree | 8519617b40132ceb353098d419a045a56a855fcf /lib/sqlalchemy/engine/base.py | |
parent | ebd24974f47f409fef785fd262087a48c02b4ff6 (diff) | |
download | sqlalchemy-87d7076b49ec52d6f890d1dc56f61ea2eb83f3a6.tar.gz |
- Added some new event mechanics for dialect-level events; the initial
implementation allows an event handler to redefine the specific mechanics
by which an arbitrary dialect invokes execute() or executemany() on a
DBAPI cursor. The new events, at this point semi-public and experimental,
are in support of some upcoming transaction-related extensions.
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
-rw-r--r-- | lib/sqlalchemy/engine/base.py | 60 |
1 files changed, 41 insertions, 19 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 5b1e61a21..6e1564c34 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -905,22 +905,39 @@ class Connection(Connectable): sql_util._repr_params(parameters, batches=10)) try: if context.executemany: - self.dialect.do_executemany( - cursor, - statement, - parameters, - context) + for fn in () if not self.dialect._has_events \ + else self.dialect.dispatch.do_executemany: + if fn(cursor, statement, parameters, context): + break + else: + self.dialect.do_executemany( + cursor, + statement, + parameters, + context) + elif not parameters and context.no_parameters: - self.dialect.do_execute_no_params( - cursor, - statement, - context) + for fn in () if not self.dialect._has_events \ + else self.dialect.dispatch.do_execute_no_params: + if fn(cursor, statement, context): + break + else: + self.dialect.do_execute_no_params( + cursor, + statement, + context) + else: - self.dialect.do_execute( - cursor, - statement, - parameters, - context) + for fn in () if not self.dialect._has_events \ + else self.dialect.dispatch.do_execute: + if fn(cursor, statement, parameters, context): + break + else: + self.dialect.do_execute( + cursor, + statement, + parameters, + context) except Exception as e: self._handle_dbapi_exception( e, @@ -995,11 +1012,16 @@ class Connection(Connectable): self.engine.logger.info(statement) self.engine.logger.info("%r", parameters) try: - self.dialect.do_execute( - cursor, - statement, - parameters, - context) + for fn in () if not self.dialect._has_events \ + else self.dialect.dispatch.do_execute: + if fn(cursor, statement, parameters, context): + break + else: + self.dialect.do_execute( + cursor, + statement, + parameters, + context) except Exception as e: self._handle_dbapi_exception( e, |