diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-05-30 20:24:08 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-05-30 20:24:08 -0400 |
| commit | 9bab63b69341bf9d89a30de2f624644b55afc6e9 (patch) | |
| tree | b1c0a4956a743ba208a0c2cf506b9fcc634ac82d /lib/sqlalchemy/engine | |
| parent | a19e403010804ad25260a96e5f38e0894c1d72af (diff) | |
| download | sqlalchemy-9bab63b69341bf9d89a30de2f624644b55afc6e9.tar.gz | |
- Pool classes will reuse the same "pool_logging_name" setting
after a dispose() occurs.
- Engine gains an "execution_options" argument and
update_execution_options() method, which will apply to
all connections generated by this engine.
- Added more aggressive caching to the mapper's usage of
UPDATE, INSERT, and DELETE expressions. Assuming the
statement has no per-object SQL expressions attached,
the expression objects are cached by the mapper after
the first create, and their compiled form is stored
persistently in a cache dictionary for the duration of
the related Engine.
- change #3 required change #1 so that we could test
a set of mappers operating over the course of many engines without
memory usage increase.
Diffstat (limited to 'lib/sqlalchemy/engine')
| -rw-r--r-- | lib/sqlalchemy/engine/__init__.py | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 27 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/threadlocal.py | 3 |
3 files changed, 29 insertions, 5 deletions
diff --git a/lib/sqlalchemy/engine/__init__.py b/lib/sqlalchemy/engine/__init__.py index 9b3dbedd8..18b25fbaa 100644 --- a/lib/sqlalchemy/engine/__init__.py +++ b/lib/sqlalchemy/engine/__init__.py @@ -164,6 +164,10 @@ def create_engine(*args, **kwargs): translations, both by engine-wide unicode conversion as well as the ``Unicode`` type object. + :param execution_options: Dictionary execution options which will + be applied to all connections. See + :meth:`~sqlalchemy.engine.base.Connection.execution_options` + :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/base.py b/lib/sqlalchemy/engine/base.py index d39880cbf..a02cb81a0 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -799,7 +799,7 @@ class Connection(Connectable): Provides execution support for string-based SQL statements as well as ClauseElement, Compiled and DefaultGenerator objects. Provides - a begin method to return Transaction objects. + a :meth:`begin` method to return Transaction objects. The Connection object is **not** thread-safe. @@ -807,7 +807,6 @@ class Connection(Connectable): single: thread safety; Connection """ - _execution_options = util.frozendict() def __init__(self, engine, connection=None, close_with_result=False, _branch=False, _execution_options=None): @@ -828,7 +827,9 @@ class Connection(Connectable): self._echo = self.engine._should_log_info() if _execution_options: self._execution_options =\ - self._execution_options.union(_execution_options) + engine._execution_options.union(_execution_options) + else: + self._execution_options = engine._execution_options def _branch(self): """Return a new Connection which references this Connection's @@ -1557,8 +1558,12 @@ class Engine(Connectable, log.Identified): """ + _execution_options = util.frozendict() + def __init__(self, pool, dialect, url, - logging_name=None, echo=None, proxy=None): + logging_name=None, echo=None, proxy=None, + execution_options=None + ): self.pool = pool self.url = url self.dialect = dialect @@ -1571,6 +1576,20 @@ class Engine(Connectable, log.Identified): self.Connection = _proxy_connection_cls(Connection, proxy) else: self.Connection = Connection + if execution_options: + self.update_execution_options(**execution_options) + + def update_execution_options(self, **opt): + """update the execution_options dictionary of this :class:`Engine`. + + For details on execution_options, see + :meth:`Connection.execution_options` as well as + :meth:`sqlalchemy.sql.expression.Executable.execution_options`. + + + """ + self._execution_options = \ + self._execution_options.union(opt) @property def name(self): diff --git a/lib/sqlalchemy/engine/threadlocal.py b/lib/sqlalchemy/engine/threadlocal.py index 001caee2a..ec2b4f302 100644 --- a/lib/sqlalchemy/engine/threadlocal.py +++ b/lib/sqlalchemy/engine/threadlocal.py @@ -37,7 +37,8 @@ class TLEngine(base.Engine): self._connections = util.threading.local() proxy = kwargs.get('proxy') if proxy: - self.TLConnection = base._proxy_connection_cls(TLConnection, proxy) + self.TLConnection = base._proxy_connection_cls( + TLConnection, proxy) else: self.TLConnection = TLConnection |
