aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2022-09-05 10:36:36 +0300
committerBonfaceKilz2022-09-08 14:26:19 +0300
commite4c0ee8816e9b09d162354c2cde511ef7a527298 (patch)
tree0e6da76137832f7e39293467efa451e163de8786
parented726c705404098f4a519b7028d69bc560ffc805 (diff)
downloadgenenetwork2-e4c0ee8816e9b09d162354c2cde511ef7a527298.tar.gz
Remove "g.db" init from every session
"g.db" is now replaced with "database_connections". * wqflask/wqflask/views.py: Remove "sqlalchemy" and "SQL_URI" imports. (connect_db): Delete it. (shutdown_session): Ditto.
-rw-r--r--wqflask/wqflask/views.py25
1 files changed, 0 insertions, 25 deletions
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index ee640726..02c534a2 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -11,7 +11,6 @@ import numpy as np
import os
import pickle as pickle
import random
-import sqlalchemy
import sys
import traceback
import uuid
@@ -68,7 +67,6 @@ from wqflask.decorators import edit_access_required
from wqflask.db_info import InfoPage
from utility import temp_data
-from utility.tools import SQL_URI
from utility.tools import TEMPDIR
from utility.tools import USE_REDIS
from utility.tools import GN_SERVER_URL
@@ -85,29 +83,6 @@ from base.webqtlConfig import GENERATED_IMAGE_DIR
Redis = get_redis_conn()
-@app.before_request
-def connect_db():
- db = getattr(g, '_database', None)
- if request.endpoint not in ("static", "js") and db is None:
- try:
- g.db = sqlalchemy.create_engine(
- SQL_URI, encoding="latin1")
- except Exception: # Capture everything
- app.logger.error(f"DATABASE: Error creating connection for: {request.endpoint}")
-
-
-@app.teardown_appcontext
-def shutdown_session(exception=None):
- db = getattr(g, '_database', None)
- if db is not None:
- try:
- g.db.dispose()
- except Exception: # Capture Everything
- app.logger.error(f"DATABASE: Error disposing: {g.db=}")
- finally: # Reset regardless of what happens
- g.db = None
-
-
@app.errorhandler(Exception)
def handle_generic_exceptions(e):
import werkzeug