This Page

The quantum.db.api Module

class quantum.db.api.MySQLPingListener

Bases: object

Ensures that MySQL connections checked out of the pool are alive.

Borrowed from: http://groups.google.com/group/sqlalchemy/msg/a4ce563d802c929f

checkout(dbapi_con, con_record, con_proxy)
class quantum.db.api.SqliteForeignKeysListener

Bases: sqlalchemy.interfaces.PoolListener

Ensures that the foreign key constraints are enforced in SQLite.

The foreign key constraints are disabled by default in SQLite, so the foreign key constraints will be enabled here for every database connection

connect(dbapi_con, con_record)
quantum.db.api.clear_db(base=<class 'sqlalchemy.ext.declarative.Base'>)
quantum.db.api.configure_db()

Establish the database, create an engine if needed, and register the models.

quantum.db.api.get_session(autocommit=True, expire_on_commit=False)

Helper method to grab session

quantum.db.api.greenthread_yield(dbapi_con, con_record)

Ensure other greenthreads get a chance to execute by forcing a context switch. With common database backends (eg MySQLdb and sqlite), there is no implicit yield caused by network I/O since they are implemented by C libraries that eventlet cannot monkey patch.

quantum.db.api.register_models(base=<class 'sqlalchemy.ext.declarative.Base'>)

Register Models and create properties

quantum.db.api.retry_registration(remaining, reconnect_interval, base=<class 'sqlalchemy.ext.declarative.Base'>)
quantum.db.api.unregister_models(base=<class 'sqlalchemy.ext.declarative.Base'>)

Unregister Models, useful clearing out data before testing