session.py 655 B

123456789101112131415161718
  1. from sqlalchemy import create_engine
  2. from sqlalchemy.orm import sessionmaker
  3. from core.config import settings
  4. # SQLALCHEMY_DATABASE_URL = settings.DATABASE_URL
  5. # engine = create_engine(SQLALCHEMY_DATABASE_URL)
  6. #if you don't want to install postgres or any database, use sqlite, a file system based database,
  7. # uncomment below lines if you would like to use sqlite and comment above 2 lines of SQLALCHEMY_DATABASE_URL AND engine
  8. SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db"
  9. engine = create_engine(
  10. SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
  11. )
  12. SessionLocal = sessionmaker(autocommit=False,autoflush=False,bind=engine)