pigeon.database.sql¶
Module Contents¶
- class pigeon.database.sql.Manager¶
Used to manage settings and load specified middleware which is only loaded at runtime.
To override settings either the method Manager.override or the Manager.__get_attr__ method is used:
# override settings using a module or similar behaving object my_settings: types.ModuleType = ... Manager.override(my_settings) # override settings one at a time by accessing the attributes (__getattr__) Manager.my_setting = my_value
- classmethod override(new_settings: types.ModuleType | Any)¶
Overrides current settings with new settings provided.
- Parameters:
new_settings – New settings to override old ones with
- pigeon.database.sql.log¶
- class pigeon.database.sql.DBManager¶
Handles interaction with databases.
- dbtype: str¶
- dbapi: str¶
- location: str¶
- engine: sqlalchemy.Engine¶
- models: list¶
- classmethod connect() None ¶
Checks if database exists and connects to it to check if connection is possible.
- property current_metadata: sqlalchemy.MetaData¶
- Classmethod:
- classmethod execute(statement) sqlalchemy.CursorResult ¶
- classmethod execute_and_commit(statement) sqlalchemy.CursorResult ¶
- classmethod autocommit_execute(statement) sqlalchemy.CursorResult ¶
- class pigeon.database.sql.MigrationManager¶
Responsible for migrations in database
- monitored_attributes¶
- classmethod migrate()¶
Migrate database to fit models provided.
The ‘_metadata’ table is a special table used to keep track of Models, therefore it will be handled differently.
- classmethod migrate_table(current: sqlalchemy.Table, target: sqlalchemy.Table) None ¶
Migrates a table from its current state to a target state, asking the user on important changes
- Parameters:
current – current table representation (state of database)
target – target table representation
- classmethod migrate_column(current: sqlalchemy.Column, target: sqlalchemy.Column) None ¶
- classmethod update_metadata()¶
Updates the ‘_metadata’ table used to keep track of table schemas