rwskit.sqlalchemy
Utilities for working with SqlAlchemy.
Attributes
A type extending |
|
The supported SQL operators for use in an |
Classes
A base class for creating declarative SqlAlchemy models from. |
|
A class that represents the basic binary expression for an SQL column. |
|
A class that represents a conjunction of SqlBinaryExpression. |
Module Contents
- rwskit.sqlalchemy.B[source]
A type extending
DeclarativeBase.
- rwskit.sqlalchemy.SqlOperator[source]
The supported SQL operators for use in an
SqlBinaryExpression.
- class rwskit.sqlalchemy.BaseModel[source]
Bases:
sqlalchemy.orm.DeclarativeBaseA base class for creating declarative SqlAlchemy models from.
This class provides functionality for finding any model derived from this clas by their table name.
- classmethod find_by_table_name(table_name: str) Type[BaseModel] | None[source]
Find a model derived from this class by its table name.
- Parameters:
table_name (str) – The name of the table whose model class you want to find.
- Returns:
Returns the model class if the table is found, otherwise
None.- Return type:
Type[FindByNameBase], optional
- class rwskit.sqlalchemy.SqlBinaryExpression[source]
Bases:
rwskit.config.YamlConfigA class that represents the basic binary expression for an SQL column.
- to_expression(model_or_table: Type[B] | sqlalchemy.Table) sqlalchemy.BinaryExpression[source]
Return a clause that can be used with an SqlAlchemy
wherestatement.- Parameters:
model_or_table (sqlalchemy.Table) – The table object that contains the column.
- Returns:
The corresponding SqlAlchemy binary expression.
- Return type:
BinaryExpression
- class rwskit.sqlalchemy.SqlSelectionCriteria[source]
Bases:
rwskit.config.YamlConfigA class that represents a conjunction of SqlBinaryExpression.
- expressions: list[SqlBinaryExpression][source]
The list of binary expressions that will be used to filter the query.