Working prototype

This commit is contained in:
2025-05-13 14:19:37 +02:00
parent 2678372ced
commit d1adfe9f93
12 changed files with 491 additions and 0 deletions

27
db/models.py Normal file
View File

@@ -0,0 +1,27 @@
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import declarative_base, sessionmaker
from sqlalchemy import create_engine
from fastapi import Depends
DATABASE_URL = "sqlite:///./test.db"
engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False})
SessionLocal = sessionmaker(bind=engine)
Base = declarative_base()
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
username = Column(String, unique=True, index=True)
role = Column(String) # z.B. "admin" oder "user"
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()