Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

22 rindas
601 B

  1. # Information about the database session is stored here
  2. from sqlalchemy import create_engine
  3. from sqlalchemy.orm import sessionmaker
  4. from core.config import settings
  5. SQLALCHEMY_DATABASE_URL = (
  6. settings.DATABASE_URL
  7. ) # get the database url from core/config.py
  8. engine = create_engine(SQLALCHEMY_DATABASE_URL)
  9. print(SQLALCHEMY_DATABASE_URL)
  10. SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
  11. def get_db(): # get the database session (if we change the database, we can change it here)
  12. db = SessionLocal()
  13. try:
  14. yield db
  15. finally:
  16. db.close()