# `ConnectionHub`

#### 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.

The ConnectionHub class is accessible via the `sqlobject.dbconnection` module.

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('...')

## Attributes

#### a `threadConnection`

    <property object at 0xa6d76e4>

## Methods

#### f `__format__(...)` ...

default object formatter

#### f `__subclasshook__(...)` ...

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

#### f `__sizeof__(...)` ...

__sizeof__() -> int size of object in memory, in bytes

#### f `__init__(self)` ...

#### f `__get__(self, obj, type=None)` ...

#### f `__set__(self, obj, value)` ...

#### f `getConnection(self)` ...

#### f `doInTransaction(self, func, *args, **kw)` ...

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.

See the source for more information.