first commit
This commit is contained in:
22
databases/sql_models/postgres_database.py
Normal file
22
databases/sql_models/postgres_database.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from api_configs import WagDatabase
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
|
||||
engine_config = {
|
||||
"url": WagDatabase.DATABASE_URL,
|
||||
"pool_size": 10,
|
||||
"max_overflow": 0,
|
||||
"echo": False,
|
||||
}
|
||||
|
||||
engine = create_engine(**engine_config)
|
||||
session_config = {"autoflush": True, "bind": engine, "echo": True}
|
||||
SessionLocal = sessionmaker(**session_config)
|
||||
session = scoped_session(sessionmaker(bind=engine))
|
||||
session.expunge_all()
|
||||
|
||||
Base = declarative_base()
|
||||
Base.session = session
|
||||
Reference in New Issue
Block a user