The command center for the models being generated
for Saffier.
PARAMETER |
DESCRIPTION |
database |
TYPE:
Database
|
**kwargs |
TYPE:
Any
DEFAULT:
{}
|
Source code in saffier/core/connection/registry.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32 | def __init__(self, database: Database, **kwargs: Any) -> None:
self.database: Database = database
self.models: Dict[str, Any] = {}
self.reflected: Dict[str, Any] = {}
self.db_schema = kwargs.get("schema", None)
self.extra: Mapping[str, Type["Database"]] = kwargs.pop("extra", {})
self.schema = Schema(registry=self)
self._metadata = (
sqlalchemy.MetaData(schema=self.db_schema)
if self.db_schema is not None
else sqlalchemy.MetaData()
)
|
database
instance-attribute
models
instance-attribute
reflected
instance-attribute
db_schema
instance-attribute
db_schema = get('schema', None)
schema
instance-attribute
schema = Schema(registry=self)
_metadata = MetaData(schema=db_schema) if db_schema is not None else MetaData()
declarative_base
cached
property
create_all
async
Source code in saffier/core/connection/registry.py
| async def create_all(self) -> None:
if self.db_schema:
await self.schema.create_schema(self.db_schema, True)
async with Database(self.database, force_rollback=False) as database:
async with database.transaction():
await database.create_all(self.metadata)
|
drop_all
async
Source code in saffier/core/connection/registry.py
| async def drop_all(self) -> None:
if self.db_schema:
await self.schema.drop_schema(self.db_schema, True, True)
async with Database(self.database, force_rollback=False) as database:
async with database.transaction():
await database.drop_all(self.metadata)
|