Cleaned up session management.
This commit is contained in:
@ -6,19 +6,19 @@ from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
db = SQLAlchemy()
|
||||
|
||||
@contextmanager
|
||||
def session_scope(engine):
|
||||
if engine:
|
||||
session = scoped_session(sessionmaker(autocommit = False, autoflush = False, bind = engine))
|
||||
#Base.query = session.query_property()
|
||||
def session_scope():
|
||||
#session = scoped_session(sessionmaker(autocommit = False, autoflush = False, bind = engine))
|
||||
session = db.session
|
||||
#Base.query = session.query_property()
|
||||
|
||||
try:
|
||||
yield session
|
||||
session.commit()
|
||||
except:
|
||||
session.rollback()
|
||||
raise
|
||||
finally:
|
||||
session.close()
|
||||
try:
|
||||
yield session
|
||||
session.commit()
|
||||
except:
|
||||
session.rollback()
|
||||
raise
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
import pkgutil
|
||||
|
||||
|
Reference in New Issue
Block a user