mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-07-11 15:33:18 +08:00
Initial commit
This commit is contained in:
22
db/session.py
Normal file
22
db/session.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from tortoise import Tortoise
|
||||
|
||||
from domain.adapters 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()
|
||||
Reference in New Issue
Block a user