fine-tuning and starting to work on account-balance

This commit is contained in:
2020-05-11 20:34:12 -05:00
parent a6e655ef72
commit d7ddf37cfa
9 changed files with 93 additions and 45 deletions

View File

@ -108,7 +108,7 @@ def init_app(app):
def get_model():
if 'model' not in g:
if 'db_model' not in g:
connection = current_app.config['PSYCOPG2_CONNECTION_POOL'].getconn()
cursor = connection.cursor()
g.db_model = DBModel(connection, cursor)
@ -116,11 +116,11 @@ def get_model():
def close_db(e=None):
model = g.pop("model", None)
db_model = g.pop("db_model", None)
if model is not None:
model.cursor.close()
current_app.config['PSYCOPG2_CONNECTION_POOL'].putconn(model.connection)
if db_model is not None:
db_model.cursor.close()
current_app.config['PSYCOPG2_CONNECTION_POOL'].putconn(db_model.connection)
def my_exec_info_message(exec_info):
return "{}: {}".format(".".join([exec_info[0].__module__, exec_info[0].__name__]), exec_info[1])