pigeon.database.models¶
Module Contents¶
- class pigeon.database.models.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.models.Field(field_type, **kwargs)¶
Singular field in database model, only used to compute sqlalchemy.Column objects for database schema
- generate(name: str | None = None)¶
Creates a sqlalchemy.Column object using the column name and the data passed to the class upon initialization
- class pigeon.database.models.Model¶
Relation in the database
- classmethod generate(metadata: sqlalchemy.MetaData) sqlalchemy.Table ¶
Transforms the fields to sqlalchemy.Columns objects
- Parameters:
metadata – sqlalchemy.MetaData object used during table creation
- Returns:
sqlalchemy.Table object representing the Model
- classmethod column(name: str) sqlalchemy.Column ¶
Returns column with the given name.
- Parameters:
name – The name of the column
- classmethod select(columns=None)¶
- classmethod delete()¶
- classmethod insert()¶
- classmethod update()¶
- classmethod all() list ¶
- class pigeon.database.models.ModelObject(model, exists=True, **kwargs)¶
Object that represents a row in a table defined by a Model, can be edited and saved back to the database
- save() None ¶
Saves the object to the database (updates/inserts the row)
- delete() None ¶
Deletes the object from the database (deletes the row)
- static from_rows(rows, model)¶
- class pigeon.database.models.Query(query, model, returns=False)¶
Represents a sql query, can be executed.
- execute() list[ModelObject] | sqlalchemy.CursorResult ¶
Runs the query and returns the result. If the query is ought to return valid data for ModelObjects, a list of ModelObjects created from the data will be returned instead
- where(*args, **kwargs)¶
- order_by(*args, **kwargs)¶
- values(*args, **kwargs)¶