The database module is accessible via the pylons module.
Provides convenient access to SQLObject-managed and/or SQLAlchemy-managed databases.
This module enables easy use of an SQLObject database by providing an auto-connect hub that will utilize the db uri string given in the Paste conf file called sqlobject.dburi.
A SQLAlchemy SessionContext is also available: it provides both thread and process safe Session objects via the session_context.current property.
{('SessionContext is deprecated. Use scoped_session().', <class sqlalchemy.logging.SADeprecationWarning at 0x245fcf0>, 142): 1}
Return the id keying the current database session's scope.
The session is particular to the current Pylons application -- this returns an id generated from the current thread and the current Pylons application's Globals object at pylons.g (if one is registered).
Return a SQLAlchemy db engine. Uses the configuration values from get_engine_conf.
Engines are cached in the get_engines dict.
Returns a dict of SQLAlchemy engine configuration values from the Pylons config file values sqlalchemy.*
Returns a SQLAlchemy session for the specified database uri from the the engine cache (returned from get_engines)``. Uses the configuration values from get_engine_conf for uri and echo when None are specified.
session_kwargs are passed to SQLAlchemy's create_session function as keyword arguments.
If the uri's engine does not exist, it will be created and added to the engine cache.
Connects to the database once per thread.
The AutoConnectHub also provides convenient methods for managing transactions.
This class contains 8 members.
Transparently proxies to an AutoConnectHub for the URI that is appropriate for this package. A package URI is configured via "packagename.dburi" in the Paste ini file settings. If there is no package DB URI configured, the default (provided by "sqlobject.dburi") is used.
The hub is not instantiated until an attempt is made to use the database.
If pool_connections=False, then a new database connection will be opened for every request. This will avoid problems with database connections that periodically die.
This class contains 4 members.
See the source for more information.