[models] make it so tortoise runs inside textual's async loop thing

This commit is contained in:
bronsen 2025-12-08 17:17:04 +01:00
parent df845c41f3
commit 221062ead5
2 changed files with 7 additions and 1 deletions

View file

@ -2,7 +2,7 @@
This file exists so the directory becomes a package.
"""
from .main import main
from teilchensammler_cli.main import main
if __name__ == "__main__":
main()

View file

@ -16,6 +16,8 @@ from textual.widgets import (
Input,
Static,
)
from tortoise import Tortoise, fields
from tortoise.models import Model
@final
@ -98,6 +100,10 @@ class AddInventoryScreen(Screen[None]):
@final
class SammlerApp(App[None]):
async def on_mount(self) -> None:
await Tortoise.init(
db_url="sqlite://db.sqlite3", modules={"models": ["teilchensammler_cli"]}
)
await Tortoise.generate_schemas()
_ = self.push_screen(AddInventoryScreen())