Package turbogears :: Module database
[hide private]

Module database

source code

Convenient access to an SQLObject or SQLAlchemy managed database.

Classes [hide private]
  Objectstore
  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 [hide private]
 
get_engine()
Retrieve the engine based on the current configuration.
source code
 
create_session()
Create a session that uses the engine from thread-local metadata.
source code
 
mapper(*args, **kwargs)
return a mapper() function which associates this ScopedSession with the Mapper.
 
bind_metadata()
Retrieve the engine based on the current configuration.
source code
 
bind_meta_data()
Retrieve the engine based on the current configuration.
source code
 
_mysql_timestamp_converter(raw)
Convert a MySQL TIMESTAMP to a floating point number representing the seconds since the Un*x Epoch.
source code
 
set_db_uri(dburi, package=None)
Sets the database URI to use either globally or for a specific package.
source code
 
commit_all()
Commits 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
 
_use_sa(args=None) source code
 
so_rwt(func, *args, **kw) source code
 
so_restart_transaction(args) source code
 
dispatch_exception(exception, args, kw) source code
 
sa_rwt(func, *args, **kw) source code
 
sa_restart_transaction(args) source code
 
make_sa_transaction(session)
Create a new transaction in an SA session.
source code
 
sa_transaction_active(transaction)
Check whether SA transaction is still active.
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 [hide private]
  log = logging.getLogger("turbogears.database")
  _engine = None
  context = session.context
  Query = sqlalchemy.Query
  session = None
  metadata = MetaData(Engine(sqlite:///:memory:))
  hub_registry = set()
  _hubs = dict()
Function Details [hide private]

_mysql_timestamp_converter(raw)

source code 

Convert a MySQL TIMESTAMP to a floating point number representing the seconds since the Un*x Epoch. It uses custom code the input seems to be the new (MySQL 4.1+) timestamp format, otherwise code from the MySQLdb module is used.

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.