Schema Creation¶
Here we create connection to SQLite database client and then we discover & initialize models.
-
async classmethod Tortoise.generate_schemas(safe=
True
)[source] Generate schemas according to models provided to
.init()
method. Will fail if schemas already exists, so it’s not recommended to be used as part of application workflow- Parameters:¶
- safe=
True
When set to true, creates the table only when it does not already exist.
- safe=
- Raises:¶
ConfigurationError – When
.init()
has not been called.- Return type:¶
None
generate_schema
generates schema on empty database.
There is also the default option when generating the schemas to set the safe
parameter to True
which will only insert the tables if they don’t already exist.