MCPcopy
hub / github.com/tortoise/tortoise-orm / generate_schemas

Method generate_schemas

tortoise/context.py:399–416  ·  view source on GitHub ↗

Generate database schemas for all models in this context. Args: safe: When True, creates tables only if they don't already exist. Raises: ConfigurationError: If context has not been initialized.

(self, safe: bool = True)

Source from the content-addressed store, hash-verified

397 router.init_routers(router_cls)
398
399 async def generate_schemas(self, safe: bool = True) -> None:
400 """
401 Generate database schemas for all models in this context.
402
403 Args:
404 safe: When True, creates tables only if they don't already exist.
405
406 Raises:
407 ConfigurationError: If context has not been initialized.
408 """
409 from tortoise.utils import generate_schema_for_client
410
411 if not self._inited:
412 raise ConfigurationError(
413 "Context not initialized. Call init() before generating schemas."
414 )
415 for connection in self.connections.all():
416 await generate_schema_for_client(connection, safe)
417
418 def get_model(self, app_label: str, model_name: str) -> type[Model]:
419 """

Callers 5

tortoise_test_contextFunction · 0.95
multi_dbFunction · 0.95
two_databasesFunction · 0.95
table_name_dbFunction · 0.95

Calls 3

ConfigurationErrorClass · 0.90
allMethod · 0.45

Tested by 4

multi_dbFunction · 0.76
two_databasesFunction · 0.76
table_name_dbFunction · 0.76