session.py 369 B

123456789101112
  1. from sqlalchemy import create_engine
  2. from sqlalchemy.orm import sessionmaker
  3. import pymysql
  4. pymysql.install_as_MySQLdb()
  5. user = "choozmo"
  6. password = "pAssw0rd"
  7. host = "db.ptt.cx:3306"
  8. db_name = "test"
  9. engine = create_engine(f'mysql://{user}:{password}@{host}/{db_name}', pool_pre_ping=True)
  10. SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)