Utilities to manipulate underlying databases - sometimes via an ORM tool.
Used to control all aspects relating to the underlying database as per the configuration of the system.
Any Reahl system is assumed to have a database backing it. Our dealings with a databases vary in two dimentions. The first of these dimantions is the different database backends that can be used. How one controls the backend itself (such as creating users, dropping databases, etc) differs depending on the particular backend used.
Regardless of which backend is used, one can also use an ORM layer on top of the database. Things like instrumenting classes, creating database tables of dealing with database transactions are dependent on the ORM implementation used.
The SystemControl allows you to control all these aspects of the database. It does so by delegating methods relating to the database backend to a
DatabaseControlof the correct kind, and by delegating the methods relating to ORM operations to an
ORMControlof the correct kind.
The type of
DatabaseControlused is inferred from the configured reahlsystem.connection_uri in reahl.config.py. The actual
ORMControlused is configured as the reahlsystem.orm_control in reahl.config.py.
A programmer should use the SystemControl of the system as programmatic interface to the database without regard for which technology-specific classes it delegates to in order to do its work.
Connects and logs into the database.
Returns True if the system is currently connected to the database.
Disconnects from the database.
Commits the database.
Rolls back the database.
Returns the current size of the database.
Creates the underlying database schema.
Removes the underlying database schema.
Ensures a new clean database exists, with a schema created. This drops an existing database if one is present.
Runs the database migrations relevant to the current system.
Computes the changes in schema iwetween the current database and what the current system expects.
Runs the all the scheduled jobs relevant to the current system.
Creates the database user.
Drops the database user.
Drops the database (if it exists).
Creates the database.
Backs up the database.
Backs up all databases on the current machine.
Restores a databases from thexs given backup.
Restores all databases from the given backup.
An interface to the underlying database backend technology used.
This class has the responsibility to manage the low-level backend operations, such as creating/dropping databases or users.
In order to support a new type of database, subclass this class and implement its methods appropriately for that backend.
An interface to higher-level database operations that may be dependent on the ORM technology used.
This class has the responsibility to manage the higher-level backend operations, such as instrumenting persisted classes, creating database schemas, migration, etc.
In order to support a new type of ORM, subclass this class and implement its methods appropriately for that ORM.