Database

Database handler base for the server’s db_registry.

Database handler — the core’s minimal contract for a mounted database.

A database declared in the config names a db_class (the imported class that builds the real db from the connection parameters) and, optionally, a db_handler_class (default AsgiDbHandlerBase). At mount time the server builds db_handler_class(db_class(**params)) and registers the handler.

The handler is what lives in the registry and what request.db returns. It proxies every attribute to the wrapped db via __getattr__ (so the db’s own interface — execute and the rest — stays transparent), while owning the one method the core itself calls: closeConnection (registered as a request cleanup). Concrete db classes and custom handlers live outside the core; the core only defines this contract.

class genro_asgi.db.AsgiDbHandlerBase(db)[source]

Bases: object

Wraps a database object: owns closeConnection, proxies the rest.

Subclass to customise lifecycle (e.g. a legacy backend); the default proxies every non-underscore attribute to the wrapped db.

closeConnection()[source]

Close the wrapped db’s connection if it exposes closeConnection.

Return type:

None