Commit 51cc9001 authored by David Trattnig's avatar David Trattnig
Browse files

Proper session scoping. #41

parent 2d0c3061
......@@ -24,28 +24,27 @@ import datetime
import sqlalchemy as sa
from sqlalchemy import BigInteger, Boolean, Column, DateTime, Integer, String, ForeignKey, ColumnDefault
from sqlalchemy import orm
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy import BigInteger, Boolean, Column, DateTime, Integer, String, ForeignKey, ColumnDefault
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
from src.base.config import AuraConfig
from src.base.utils import SimpleUtil
from src.core.resources import ResourceUtil
# Init Config
config = AuraConfig()
from src.base.config import AuraConfig
from src.base.utils import SimpleUtil
from src.core.resources import ResourceUtil
# Initialize DB Model and session
config = AuraConfig()
engine = sa.create_engine(config.get_database_uri())
Base = declarative_base()
Base.metadata.bind = engine
class DB():
session = orm.scoped_session(orm.sessionmaker())(bind=engine)
session_factory = sessionmaker(bind=engine)
Session = scoped_session(session_factory)
session = Session()
Model = Base
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment