import os from sqlmodel import create_engine, SQLModel, Session DATABASE_URL = os.environ.get("DATABASE_URL") # The major differences between SQLModel's create_engine and SQLAlchemy's # version is that the SQLModel version adds type annotations (for editor support) # and enables the SQLAlchemy "2.0" style of engines and connections. engine = create_engine(DATABASE_URL, echo=True) # Will want a "debug mode where it doesn't echo for prod def init_db(): SQLModel.metadata.create_all(engine) def get_session(): """A coroutine function for getting a database session.""" with Session(engine) as session: yield session