mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-05-06 18:22:44 +08:00
24 lines
515 B
Python
24 lines
515 B
Python
from tortoise import Tortoise
|
|
|
|
from services.adapters.registry import runtime_registry
|
|
|
|
TORTOISE_ORM = {
|
|
"connections": {"default": "sqlite://data/db/db.sqlite3"},
|
|
"apps": {
|
|
"models": {
|
|
"models": ["models.database"],
|
|
"default_connection": "default",
|
|
}
|
|
},
|
|
}
|
|
|
|
|
|
async def init_db():
|
|
await Tortoise.init(config=TORTOISE_ORM)
|
|
await Tortoise.generate_schemas()
|
|
await runtime_registry.refresh()
|
|
|
|
|
|
async def close_db():
|
|
await Tortoise.close_connections()
|