poppy.core.db.database module

class poppy.core.db.database.Database(name, *args, **kwargs)[source]

Bases: poppy.core.generic.signals.Signal

A class to manage the connection status to the database and inform all the other controllers connected to this class that the connection appeared or is gone.

bases_manager = <poppy.core.db.database.BaseManager object>
configure()[source]

To bind the session to the engine.

connectDatabase()[source]

To make a connection to the database through SQLAlchemy with the parameters in the configuration file.

connectDatabaseAdmin()[source]

To make a connection to the database through SQLAlchemy with the parameters in the configuration file.

classmethod connection(name)[source]

A decorator in order to provide a wrapper connector to a given database, not polluting too much the code with redundant instructions.

create_connection()[source]
create_engine(admin=False)[source]

Create the engine associated to the url of this database.

generate_url()[source]

Generate the URL of the database from the parameters.

generate_url_admin()[source]

Generate the URL of the database from the parameters, using database admin

is_available()[source]

From the package sqlalchemy-utils to check if the database exists, i.e. is connected or not.

is_available_with_error()[source]
classmethod is_connected(name)[source]

Decorator to ensure that a connection exists before running the it.

makeConnections(connected)[source]

To make the appropriate connections to the database.

makeConnectionsAdmin(connected)[source]

To make the appropriate connections to the database.

manager = <poppy.core.generic.manager.Manager object>
parameters
query_context()[source]

A context manager to create a session for a query and be able to close correctly the session when finished, errors, etc.

reflect()[source]

To make the reflection of model classes to the database for the current engine, in order to be able to use those classes instances as representation of databases.

scoped_session

A descriptor to cache the execution of a property, and sending the computed value again and again.

unbind()[source]

To indicate that the database is no more binded, allowing to rebind it to a new engine.

exception poppy.core.db.database.DatabaseException[source]

Bases: Exception