Package turbogears :: Module database

Module database

source code

Convenient access to an SQLObject or SQLAlchemy managed database.

Classes
  DatabaseError
TurboGears Database Error.
  DatabaseConfigurationError
TurboGears Database Configuration Error.
  AutoConnectHub
  PackageHub
Functions
 
create_session_mapper(scoped_session=session) 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)
Set the database URI.
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
 
EndTransactions() source code
Variables
  metadata = MetaData(None)
  session = session
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 

Set the database URI.

Sets the database URI to use either globally or for a specific package. Note that once the database is accessed, calling it 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.