Package turbogears :: Module database

Module database

source code

Convenient access to an SQLObject or SQLAlchemy managed database.

Classes
  DatabaseError
  DatabaseConfigurationError
  AutoConnectHub
Connects to the database once per thread.
  PackageHub
Transparently proxies to an AutoConnectHub for the URI that is appropriate for this package.
  EndTransactionsFilter
Functions
 
create_session_mapper(scoped_session=None) source code
 
session_mapper(cls, *args, **kw) source code
 
get_engine(pkg=None)
Retrieve the engine based on the current configuration.
source code
 
get_metadata(pkg=None)
Retrieve the metadata for the specified package.
source code
 
bind_metadata()
Connect SQLAlchemy to the configured database(s).
source code
 
create_session()
Create a session that uses the engine from thread-local metadata.
source code
 
mapper(*args, **kwargs)
return a :func:`.mapper` function which associates this ScopedSession with the Mapper.
 
set_db_uri(dburi, package=None)
Sets the database URI to use either globally or for a specific package.
source code
 
commit_all()
Commit the transactions in all registered hubs (for this thread).
source code
 
rollback_all()
Rollback the transactions in all registered hubs (for this thread).
source code
 
end_all()
End the transactions in all registered hubs (for this thread).
source code
 
so_to_dict(sqlobj)
Convert SQLObject to a dictionary based on columns.
source code
 
so_columns(sqlclass, columns=None)
Return a dict with all columns from a SQLObject.
source code
 
so_joins(sqlclass, joins=None)
Return a list with all joins from a SQLObject.
source code
Variables
  metadata = MetaData(None)
  session = None
Function Details

create_session()

source code 

Create a session that uses the engine from thread-local metadata.

The session by default does not begin a transaction, and requires that flush() be called explicitly in order to persist results to the database.

mapper(*args, **kwargs)

 

return a :func:`.mapper` function which associates this ScopedSession with the Mapper.

.. deprecated:: 0.5 :meth:`.ScopedSession.mapper` is deprecated. Please see http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionAwareMapper for information on how to replicate its behavior.

set_db_uri(dburi, package=None)

source code 

Sets the database URI to use either globally or for a specific package. Note that once the database is accessed, calling setDBUri will have no effect.

Parameters:
  • dburi - database URI to use
  • package - package name this applies to, or None to set the default.

so_columns(sqlclass, columns=None)

source code 

Return a dict with all columns from a SQLObject.

This includes the columns from InheritableSO's bases.

so_joins(sqlclass, joins=None)

source code 

Return a list with all joins from a SQLObject.

The list includes the columns from InheritableSO's bases.