from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker # Define the location of our SQLite database file. # The ./. indicates it will be in the same directory as our project. SQLALCHEMY_DATABASE_URL = "sqlite:///./multichat_overlay.db" # Create the SQLAlchemy engine. The `connect_args` is needed only for SQLite # to allow it to be used by multiple threads, which FastAPI does. engine = create_engine( SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False} ) # Each instance of SessionLocal will be a database session. SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) # This Base will be used by our model classes to inherit from. Base = declarative_base()