sqlobject.dbconnection module

class sqlobject.dbconnection.Boolean[source]

Bases: object

A bool class that also understands some special string keywords

Understands: yes/no, true/false, on/off, 1/0, case ignored.

class sqlobject.dbconnection.ConnMethodWrapper(method, connection)[source]

Bases: object

class sqlobject.dbconnection.ConnWrapper(soClass, connection)[source]

Bases: object

This represents a SQLObject class that is bound to a specific connection (instances have a connection instance variable, but classes are global, so this is binds the connection variable lazily when a class method is accessed)

class sqlobject.dbconnection.ConnectionHub[source]

Bases: object

This object serves as a hub for connections, so that you can pass in a ConnectionHub to a SQLObject subclass as though it was a connection, but actually bind a real database connection later. You can also bind connections on a per-thread basis.

You must hang onto the original ConnectionHub instance, as you cannot retrieve it again from the class or instance.

To use the hub, do something like:

hub = ConnectionHub()
class MyClass(SQLObject):
    _connection = hub

hub.threadConnection = connectionFromURI('...')
doInTransaction(func, *args, **kw)[source]

This routine can be used to run a function in a transaction, rolling the transaction back if any exception is raised from that function, and committing otherwise.

Use like:

sqlhub.doInTransaction(process_request, os.environ)

This will run process_request(os.environ). The return value will be preserved.

getConnection()[source]
threadConnection
class sqlobject.dbconnection.ConnectionURIOpener[source]

Bases: object

connectionForURI(uri, oldUri=False, **args)[source]
dbConnectionForScheme(scheme)[source]
registerConnection(schemes, builder)[source]
registerConnectionInstance(inst)[source]
class sqlobject.dbconnection.ConsoleWriter(connection, loglevel)[source]
write(text)[source]
class sqlobject.dbconnection.DBAPI(**kw)[source]

Bases: sqlobject.dbconnection.DBConnection

Subclass must define a makeConnection() method, which returns a newly-created connection object.

queryInsertID must also be defined.

accumulateSelect(select, *expressions)[source]

Apply an accumulate function(s) (SUM, COUNT, MIN, AVG, MAX, etc...) to the select object.

clearTable(tableName)[source]
close()[source]
createBinary(value)[source]

Create a binary object wrapper for the given database.

createColumn(soClass, col)[source]
createColumns(soClass)[source]
createEmptyDatabase()[source]

Create an empty database.

createIndexSQL(soClass, index)[source]
createReferenceConstraint(soClass, col)[source]
createReferenceConstraints(soClass)[source]
createSQL(soClass)[source]
createTable(soClass)[source]
createTableSQL(soClass)[source]
dbName = None
dropTable(tableName, cascade=False)[source]
getConnection()[source]
iterSelect(select)[source]
printDebug(conn, s, name, type='query')[source]
query(s)[source]
queryAll(s)[source]
queryAllDescription(s)[source]
queryForSelect(select)[source]
queryInsertID(soInstance, id, names, values)[source]
queryOne(s)[source]
releaseConnection(conn, explicit=False)[source]
sqlrepr(v)[source]
transaction()[source]
class sqlobject.dbconnection.DBConnection(name=None, debug=False, debugOutput=False, cache=True, style=None, autoCommit=True, debugThreading=False, registry=None, logger=None, loglevel=None)[source]
classmethod connectionFromOldURI(uri)[source]
classmethod connectionFromURI(uri)[source]
expireAll()[source]

Expire all instances of objects for this connection.

oldUri()[source]
soClassAdded(soClass)[source]

This is called for each new class; we use this opportunity to create an instance method that is bound to the class and this connection.

uri()[source]
class sqlobject.dbconnection.Iteration(dbconn, rawconn, select, keepConnection=False)[source]

Bases: object

next()[source]
class sqlobject.dbconnection.LogWriter(connection, logger, loglevel)[source]
write(text)[source]
class sqlobject.dbconnection.Transaction(dbConnection)[source]

Bases: object

assertActive()[source]
begin()[source]
close()[source]
commit(close=False)[source]
iterSelect(select)[source]
query(s)[source]
queryAll(s)[source]
queryInsertID(soInstance, id, names, values)[source]
queryOne(s)[source]
rollback()[source]
sqlobject.dbconnection.makeDebugWriter(connection, loggerName, loglevel)[source]