summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/strategies.py
Commit message (Collapse)AuthorAgeFilesLines
* Integrate "pre-ping" into connection pool.Mike Bayer2017-03-201-1/+2
| | | | | | | | | | | | | | | Added native "pessimistic disconnection" handling to the :class:`.Pool` object. The new parameter :paramref:`.Pool.pre_ping`, available from the engine as :paramref:`.create_engine.pool_pre_ping`, applies an efficient form of the "pre-ping" recipe featured in the pooling documentation, which upon each connection check out, emits a simple statement, typically "SELECT 1", to test the connection for liveness. If the existing connection is no longer able to respond to commands, the connection is transparently recycled, and all other connections made prior to the current timestamp are invalidated. Change-Id: I89700d0075e60abd2250e54b9bd14daf03c71c00 Fixes: #3919
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Additions to support HAAlchemy pluginMike Bayer2016-09-161-1/+12
| | | | | | | | | | | | | | | | | | | - add a connect=True key to connection record to support pre-loading of _ConnectionRecord objects - ensure _ConnectionRecord.close() leaves the record in a good state for reopening - add _ConnectionRecord.record_info for persistent storage - add "in_use" accessor based on fairy_ref being present or not - allow for the exclusions system and SuiteRequirements to be usable without the full plugin_base setup. - move some Python-env requirements to the importable requirements.py module. - allow starttime to be queried - add additional events for engine plugins - have "dialect" be a first-class parameter to the pool, ensure the engine strategy supplies it up front Change-Id: Ibf549f7a1766e49d335cd6f5e26bacfaef9a8229
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - reorganize schema_translate_map to be succinct and gain the performanceMike Bayer2016-01-111-3/+3
| | | | back by using an attrgetter for the default case
* - Multi-tenancy schema translation for :class:`.Table` objects is added.Mike Bayer2016-01-081-0/+3
| | | | | | | | | This supports the use case of an application that uses the same set of :class:`.Table` objects in many schemas, such as schema-per-user. A new execution option :paramref:`.Connection.execution_options.schema_translate_map` is added. fixes #2685 - latest tox doesn't like the {posargs} in the profile rerunner
* - Added a new entrypoint system to the engine to allow "plugins" toMike Bayer2016-01-061-0/+7
| | | | | | | | | | | be stated in the query string for a URL. Custom plugins can be written which will be given the chance up front to alter and/or consume the engine's URL and keyword arguments, and then at engine create time will be given the engine itself to allow additional modifications or event registration. Plugins are written as a subclass of :class:`.CreateEnginePlugin`; see that class for details. fixes #3536
* - fix some tests related to the URL change and try to makeMike Bayer2015-05-231-1/+2
| | | | the URL design a little simpler
* - Adjustments to the engine plugin hook, such that theMike Bayer2015-05-221-2/+1
| | | | | | | | :meth:`.URL.get_dialect` method will continue to return the ultimate :class:`.Dialect` object when a dialect plugin is used, without the need for the caller to be aware of the :meth:`.Dialect.get_dialect_cls` method. reference #3379
* - New features added to support engine/pool plugins with advancedMike Bayer2015-04-301-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | functionality. Added a new "soft invalidate" feature to the connection pool at the level of the checked out connection wrapper as well as the :class:`._ConnectionRecord`. This works similarly to a modern pool invalidation in that connections aren't actively closed, but are recycled only on next checkout; this is essentially a per-connection version of that feature. A new event :class:`.PoolEvents.soft_invalidate` is added to complement it. fixes #3379 - Added new flag :attr:`.ExceptionContext.invalidate_pool_on_disconnect`. Allows an error handler within :meth:`.ConnectionEvents.handle_error` to maintain a "disconnect" condition, but to handle calling invalidate on individual connections in a specific manner within the event. - Added new event :class:`.DialectEvents.do_connect`, which allows interception / replacement of when the :meth:`.Dialect.connect` hook is called to create a DBAPI connection. Also added dialect plugin hooks :meth:`.Dialect.get_dialect_cls` and :meth:`.Dialect.engine_created` which allow external plugins to add events to existing dialects using entry points. fixes #3355
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - The engine-level error handling and wrapping routines will nowMike Bayer2014-12-051-10/+1
| | | | | | | | | take effect in all engine connection use cases, including when user-custom connect routines are used via the :paramref:`.create_engine.creator` parameter, as well as when the :class:`.Connection` encounters a connection error on revalidation. fixes #3266
* - adjustment for ref #3200 as we need an immutabledict() here soMike Bayer2014-10-071-1/+1
| | | | | that union() can be called, in the case of a dialect that uses execution options inside of initialize() (e.g. oursql)
* - The execution options passed to an :class:`.Engine` either viaMike Bayer2014-10-061-0/+1
| | | | | | | | | | | | | | :paramref:`.create_engine.execution_options` or :meth:`.Engine.update_execution_options` are not passed to the special :class:`.Connection` used to initialize the dialect within the "first connect" event; dialects will usually perform their own queries in this phase, and none of the current available options should be applied here. In particular, the "autocommit" option was causing an attempt to autocommit within this initial connect which would fail with an AttributeError due to the non-standard state of the :class:`.Connection`. fixes #3200
* PEP8 style fixesBrian Jarrett2014-07-131-6/+6
|
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* - vastly improve the "safe close cursor" tests in test_reconnectMike Bayer2014-05-301-1/+0
| | | | | | | | | | | - Fixed bug which would occur if a DBAPI exception occurs when the engine first connects and does its initial checks, and the exception is not a disconnect exception, yet the cursor raises an error when we try to close it. In this case the real exception would be quashed as we tried to log the cursor close exception via the connection pool and failed, as we were trying to access the pool's logger in a way that is inappropriate in this very specific scenario. fixes #3063
* - Added a new keyword argument ``once=True`` to :func:`.event.listen`Mike Bayer2014-03-111-2/+1
| | | | | and :func:`.event.listens_for`. This is a convenience feature which will wrap the given listener such that it is only invoked once.
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - The :func:`.engine_from_config` function has been improved so thatMike Bayer2013-12-071-8/+17
| | | | | | | | we will be able to parse dialect-specific arguments from string configuration dictionaries. Dialect classes can now provide their own list of parameter types and string-conversion routines. The feature is not yet used by the built-in dialects, however. [ticket:2875]
* - A DBAPI that raises an error on ``connect()`` which is not a subclassMike Bayer2013-12-071-1/+1
| | | | | | | | | | | | of dbapi.Error (such as ``TypeError``, ``NotImplementedError``, etc.) will propagate the exception unchanged. Previously, the error handling specific to the ``connect()`` routine would both inappropriately run the exception through the dialect's :meth:`.Dialect.is_disconnect` routine as well as wrap it in a :class:`sqlalchemy.exc.DBAPIError`. It is now propagated unchanged in the same way as occurs within the execute process. [ticket:2881] - add tests for this in test_parseconnect, but also add tests in test_execute to ensure the execute() behavior as well
* Dialect.initialize() is not called a second time if an :class:`.Engine`Mike Bayer2013-07-111-0/+1
| | | | | | is recreated, due to a disconnect error. This fixes a particular issue in the Oracle 8 dialect, but in general the dialect.initialize() phase should only be once per dialect. Also in 0.8.3. [ticket:2776]
* - refactor pool a bit so that intent between ↵Mike Bayer2013-07-021-7/+2
| | | | | | | | | | | | | | ConnectionRecord/ConnectionFairy is clear; make sure that the DBAPI connection passed to the reset-on-return events/dialect hooks is also a "fairy", so that dictionaries like "info" are available. [ticket:2770] - rework the execution_options system so that the dialect is given the job of making any immediate adjustments based on a set event. move the "isolation level" logic to use this new system. Also work things out so that even engine-level execution options can be used for things like isolation level; the dialect attaches a connect-event handler in this case to handle the task. - to support this new system as well as further extensibiltiy of execution options add events engine_connect(), set_connection_execution_options(), set_engine_execution_options()
* import of "sqlalchemy" and "sqlalchemy.orm" works.Mike Bayer2013-04-271-13/+6
|
* - the raw 2to3 runMike Bayer2013-04-271-12/+13
| | | | - went through examples/ and cleaned out excess list() calls
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* just a pep8 pass of lib/sqlalchemy/engine/Diana Clarke2012-11-191-14/+16
|
* -whitespace bonanza, contdMike Bayer2012-07-281-3/+3
|
* typos in lib/sqlalchemy/engineDiana Clarke2012-03-171-3/+3
|
* - [bug] Added execution_options() call toMike Bayer2012-02-131-0/+3
| | | | | | MockConnection (i.e., that used with strategy="mock") which acts as a pass through for arguments.
* - [feature] Added pool_reset_on_return argumentMike Bayer2012-02-011-1/+2
| | | | | | | | to create_engine, allows control over "connection return" behavior. Also added new arguments 'rollback', 'commit', None to pool.reset_on_return to allow more control over connection return activity. [ticket:2378]
* - [bug] Fixed bug in "mock" strategy wherebyMike Bayer2012-01-281-3/+3
| | | | | | correct DDL visit method wasn't called, resulting in "CREATE/DROP SEQUENCE" statements being duplicated [ticket:2384]
* happy new yearMike Bayer2012-01-041-1/+1
|
* - fix up the invalidate on connect for py3kMike Bayer2011-07-061-2/+6
| | | | - fix the test for separately installed pysqlite
* - Failures on connect which raise dbapi.ErrorMike Bayer2011-07-011-1/+2
| | | | | | | | | | | | will forward the error to dialect.is_disconnect() and set the "connection_invalidated" flag if the dialect knows this to be a potentially "retryable" condition. Only Oracle ORA-01033 implemented for now. [ticket:2201] - Added ORA-01033 to disconnect codes, which can be caught during a connection event. [ticket:2201]
* - Deprecate schema/SQL-oriented methods onMike Bayer2011-06-021-0/+7
| | | | | | | Connection/Engine that were never well known and are redundant: reflecttable(), create(), drop(), text(), engine.func - lots of docstrings in engine
* - rename EngineEvents to ConnectionEventsMike Bayer2011-02-171-0/+7
| | | | | | | | - simplify connection event model to be inline inside Connection, don't use ad-hoc subclasses (technically would leak memory for the app that keeps creating engines and adding events) - not doing listen-per-connection yet. this is closer. overall things are much simpler now (until we put listen-per-connection in...)
* - py3k fix regarding new exception systemMike Bayer2011-02-091-1/+1
| | | | | - this test keeps throwing a TNS error on Oracle on the buildbot only, runs locally, seems to be related to some scaling/memory type of issue on the bot
* - Non-DBAPI errors which occur in the scope of an `execute()`Mike Bayer2011-02-091-2/+5
| | | | | | | | call are now wrapped in sqlalchemy.exc.StatementError, and the text of the SQL statement and repr() of params is included. This makes it easier to identify statement executions which fail before the DBAPI becomes involved. [ticket:2015]
* - whitespace removal bonanzaMike Bayer2011-01-021-11/+11
|
* - clean up copyright, update for 2011, stamp every file withMike Bayer2011-01-021-0/+6
| | | | | a consistent tag - AUTHORS file
* - removes the "on_" prefix.Mike Bayer2010-12-301-3/+3
|
* new calling style: event.listen(target, identifier, fn)Mike Bayer2010-12-011-3/+3
|
* - NullPool is now used by default for SQLite file-Mike Bayer2010-11-281-6/+3
| | | | | | based databases. :memory: databases will continue to select SingletonThreadPool by default. [ticket:1921]
* - fixes for PG, mysql, twophaseMike Bayer2010-11-201-0/+1
| | | | | - added "pool_events" arg to create_engine(), "events" to pool, allowing establishment of listeners which fire before those of the dialect
* going back to the simple way, plus trying to make the engine thing simpler, ↵Mike Bayer2010-08-281-3/+3
| | | | | | | and....doesn't work. on_before_execute and on_after_execute really not appealing here. might have to just go back to what it was the other day.
* - its probably worthwhile to make the primary listen() interface humane, i.e.:Mike Bayer2010-08-271-3/+3
| | | | | | | | | | | | | | | | def listen(target, args) so here we provide a "wrapper" approach that allows this, and it is basically pass-by-value. a pass-by-value event *may* support rewriting some of the args in the dictionary. the current listen will become "listen_raw" since it saves about 100% overhead versus the coercion to dict, and will be used internally, and will remain pass-by-reference. proxyconnection probably will rely upon the newer style of pass-by-value for "rewrite the args" types of calls.
* - worked it out so that classes declare a nested class "event",Mike Bayer2010-07-241-8/+9
| | | | | | | | | with methods representing events. This is self-documenting via sphinx. - implemented new model for pool, classmanager. Most events are one or two args, so going back to allowing any kind of *arg, **kw signature for events - this is simpler and improves performance, though we don't get the "we can add new kw's anytime". perhaps there's some other way to approach that.
* - The visit_pool() method of Dialect is removed, and replaced withMike Bayer2010-03-151-2/+10
| | | | | | | | on_connect(). This method returns a callable which receives the raw DBAPI connection after each one is created. The callable is assembled into a first_connect/connect pool listener by the connection strategy if non-None. Provides a simpler interface for dialects.
* - Added "logging_name" argument to create_engine(), Pool() constructorMike Bayer2010-03-131-1/+2
| | | | | | | as well as "pool_logging_name" argument to create_engine() which filters down to that of Pool. Issues the given string name within the "name" field of logging messages instead of the default hex identifier string. [ticket:1555]