session.py 539 B

12345678910111213141516171819
  1. from sqlalchemy import create_engine
  2. from sqlalchemy.ext.declarative import declarative_base
  3. from sqlalchemy.orm import sessionmaker
  4. from app.core.config import settings
  5. SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db"
  6. engine = create_engine(
  7. SQLALCHEMY_DATABASE_URL,
  8. connect_args={"check_same_thread": False},
  9. # settings.SQLALCHEMY_DATABASE_URL,
  10. # pool_pre_ping=True,
  11. pool_size=256,
  12. # max_overflow=2000,
  13. )
  14. SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
  15. Base = declarative_base()