def _get_db_session():
'we can call this from scripts to access valid DBSession'
# not sure we want to do it this way - but let's use for now
session = DBSession()
try:
eng = session.get_bind()
if eng.url.database.split(os.path.sep)[-2:] != [__module_folder__,
_db_file]:
raise UnboundExecutionError
except UnboundExecutionError:
session.bind = create_engine('sqlite:///' + _db_file_path)
return session
评论列表
文章目录