trulens.core.database.orm¶
trulens.core.database.orm
¶
Attributes¶
Classes¶
BaseWithTablePrefix
¶
ORM base class except with __tablename__
defined in terms
of a base name and a prefix.
A subclass should set _table_base_name and/or _table_prefix. If it does not
set both, make sure to set __abstract__ = True
. Current design has
subclasses set _table_base_name
and then subclasses of that subclass
setting _table_prefix
as in make_orm_for_prefix
.
Functions¶
new_base
cached
¶
Create a new base class for ORM classes.
Note: This is a function to be able to define classes extending different SQLAlchemy declarative bases. Each different such bases has a different set of mappings from classes to table names. If we only had one of these, our code will never be able to have two different sets of mappings at the same time. We need to be able to have multiple mappings for performing things such as database migrations and database copying from one database configuration to another.
new_orm
¶
Create a new orm container from the given base table class.
make_base_for_prefix
cached
¶
make_base_for_prefix(
base: Type[T],
table_prefix: str = DEFAULT_DATABASE_PREFIX,
) -> Type[T]
Create a base class for ORM classes with the given table name prefix.
PARAMETER | DESCRIPTION |
---|---|
base
|
Base class to extend. Should be a subclass of BaseWithTablePrefix.
TYPE:
|
table_prefix
|
Prefix to use for table names.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Type[T]
|
A class that extends |
make_orm_for_prefix
cached
¶
make_orm_for_prefix(
table_prefix: str = DEFAULT_DATABASE_PREFIX,
) -> Type[ORM[T]]
Make a container for ORM classes.
This is done so that we can use a dynamic table name prefix and make the ORM classes based on that.
PARAMETER | DESCRIPTION |
---|---|
table_prefix
|
Prefix to use for table names.
TYPE:
|