main: don't add fake data during start up
This commit is contained in:
parent
b068bd1e2a
commit
d6bcb90431
1 changed files with 1 additions and 23 deletions
|
|
@ -4,12 +4,10 @@ This is where the application is implemented.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from sqlmodel import Session
|
|
||||||
from textual.app import App
|
from textual.app import App
|
||||||
from textual.logging import TextualHandler
|
from textual.logging import TextualHandler
|
||||||
|
|
||||||
from .database import create_db_and_tables, engine
|
from .database import create_db_and_tables
|
||||||
from .models import Teilchen, make_teilchen_input
|
|
||||||
from .tui import AddInventoryScreen
|
from .tui import AddInventoryScreen
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
|
|
@ -19,29 +17,9 @@ logging.basicConfig(
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
FAKE_INPUT = """
|
|
||||||
Ein Teilchen. #Tag03 #tag12 "Dieses Teilchen ist nur zum testen" #tag1 #tag2
|
|
||||||
""".strip(" \n")
|
|
||||||
|
|
||||||
|
|
||||||
async def try_this():
|
|
||||||
teilchen_data = await make_teilchen_input(FAKE_INPUT)
|
|
||||||
if not teilchen_data:
|
|
||||||
logger.error("oh no!")
|
|
||||||
|
|
||||||
with Session(engine) as session:
|
|
||||||
db_teilchen = Teilchen.model_validate(teilchen_data)
|
|
||||||
session.add(db_teilchen)
|
|
||||||
session.commit()
|
|
||||||
session.refresh(db_teilchen)
|
|
||||||
|
|
||||||
logger.info(f"{db_teilchen=}")
|
|
||||||
|
|
||||||
|
|
||||||
class SammlerApp(App[None]):
|
class SammlerApp(App[None]):
|
||||||
async def on_mount(self) -> None:
|
async def on_mount(self) -> None:
|
||||||
create_db_and_tables()
|
create_db_and_tables()
|
||||||
try_this()
|
|
||||||
_ = self.push_screen(AddInventoryScreen())
|
_ = self.push_screen(AddInventoryScreen())
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue