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

Function generate_schema_for_client

tortoise/utils.py:35–46  ·  view source on GitHub ↗

Generates and applies the SQL schema directly to the given client. :param client: The DB client to generate Schema SQL for :param safe: When set to true, creates the table only when it does not already exist.

(client: BaseDBAsyncClient, safe: bool)

Source from the content-addressed store, hash-verified

33
34
35async def generate_schema_for_client(client: BaseDBAsyncClient, safe: bool) -> None:
36 """
37 Generates and applies the SQL schema directly to the given client.
38
39 :param client: The DB client to generate Schema SQL for
40 :param safe: When set to true, creates the table only when it does not already exist.
41 """
42 generator = client.schema_generator(client)
43 schema = get_schema_sql(client, safe)
44 logger.debug("Creating schema: %s", schema)
45 if schema: # pragma: nobranch
46 await generator.generate_from_string(schema)
47
48
49def chunk(instances: Iterable[Any], batch_size: int | None = None) -> Iterable[Iterable[Any]]:

Callers 2

generate_schemasMethod · 0.90
generate_schemasMethod · 0.90

Calls 2

get_schema_sqlFunction · 0.85
generate_from_stringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…