db
Deprecated since version 0.15.0: The mautrix.util.async_db
utility is now recommended over SQLAlchemy.
- class mautrix.util.db.Base
Bases:
mautrix.util.db.base.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 (sqlalchemy.engine.base.Engine) –
- Return type
- classmethod copy(bind=None, rebase=None)
- Parameters
bind (Optional[sqlalchemy.engine.base.Engine]) –
rebase (Optional[sqlalchemy.ext.declarative.declarative_base]) –
- Return type
Type[mautrix.util.db.base.T]
- edit(*, _update_values=True, **values)
Edit this row.
- 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 (mautrix.util.db.base.T) –
- Return type
- 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
mautrix.util.db.base.T
- db: sqlalchemy.engine.base.Engine
- t: sqlalchemy.sql.schema.Table
- c: sqlalchemy.sql.base.ImmutableColumnCollection