db
Deprecated since version 0.15.0: The mautrix.util.async_db
utility is now recommended over SQLAlchemy.
- class mautrix.util.db.Base
Bases:
Base
Deprecated since version 0.15.0: The
mautrix.util.async_db
utility is now recommended over SQLAlchemy.- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- metadata = MetaData()
- registry = <sqlalchemy.orm.decl_api.registry object>
- class mautrix.util.db.BaseClass
Bases:
object
Base class for SQLAlchemy models. Provides SQLAlchemy declarative base features and some additional utilities.
Deprecated since version 0.15.0: The
mautrix.util.async_db
utility is now recommended over SQLAlchemy.- classmethod bind(db_engine)
- Parameters:
db_engine (Engine)
- Return type:
None
- classmethod copy(bind=None, rebase=None)
- Parameters:
bind (Engine | None)
rebase (declarative_base | None)
- Return type:
Type[T]
- delete()
Delete this row.
- Parameters:
self (T)
- Return type:
None
- edit(*, _update_values=True, **values)
Edit this row.
- Parameters:
_update_values (bool) – Whether or not the values in memory should be updated as well as the values in the database.
**values – The values to change.
self (T)
- Return type:
None
- edit_mode()
Edit this row in a fancy context manager way. This stores the current edit identity, then yields to the context manager and finally puts the new values into the row using the old edit identity in the WHERE clause.
>>> class TableClass(Base): ... ... >>> db_instance = TableClass(id="something")
>>> with db_instance.edit_mode(): ... db_instance.id = "new_id"
- Parameters:
self (T)
- Return type:
None
- insert()
- Return type:
None
- classmethod scan(row)
Read the data from a row into an object.
- Parameters:
row (RowProxy) – The RowProxy object.
- Returns:
An object containing the information in the row.
- Return type:
T
- upsert()
- Parameters:
self (T)
- Return type:
None
- db: Engine
- t: Table
- c: ImmutableColumnCollection