restructure

This commit is contained in:
matthias@matsewe.de
2024-05-22 19:44:24 +02:00
parent 32d2170a1b
commit f6016f5736
11 changed files with 195 additions and 115 deletions

25
app/database.py Normal file
View File

@@ -0,0 +1,25 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, DeclarativeBase
from sqlalchemy.types import PickleType
import os
SQLALCHEMY_DATABASE_URL = "sqlite:///" + os.environ.get("DATABASE_URL", "/data/db.sqlite")
engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
async def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
class Base(DeclarativeBase):
type_annotation_map = {
dict[str, bool]: PickleType
}