about summary refs log tree commit diff
path: root/uploader/phenotypes
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-11-22 12:16:28 -0600
committerFrederick Muriuki Muriithi2024-11-22 12:16:28 -0600
commit8a84c4d6762446e5fdf9f9121f539c89419ae6a0 (patch)
tree0c4d175767bdfb24d83a7f0c15e0ab677e00ebba /uploader/phenotypes
parent82fb92db448f1985b821193bcfdee72d512e27bb (diff)
downloadgn-uploader-8a84c4d6762446e5fdf9f9121f539c89419ae6a0.tar.gz
Use gn-libs code for db connection.
Use the code in gn-libs to connect to the database, rather than a
local module.
Diffstat (limited to 'uploader/phenotypes')
-rw-r--r--uploader/phenotypes/models.py9
-rw-r--r--uploader/phenotypes/views.py2
2 files changed, 6 insertions, 5 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index 9324601..73b1cce 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -5,8 +5,9 @@ from datetime import datetime
 
 import MySQLdb as mdb
 from MySQLdb.cursors import Cursor, DictCursor
+from flask import current_app as app
 
-from uploader.db_utils import debug_query
+from gn_libs.mysqldb import debug_query
 
 def datasets_by_population(
         conn: mdb.Connection,
@@ -68,7 +69,7 @@ def dataset_phenotypes(conn: mdb.Connection,
             f" LIMIT {limit} OFFSET {offset}" if bool(limit) else "")
     with conn.cursor(cursorclass=DictCursor) as cursor:
         cursor.execute(_query, (population_id, dataset_id))
-        debug_query(cursor)
+        debug_query(cursor, app.logger)
         return tuple(dict(row) for row in cursor.fetchall())
 
 
@@ -201,7 +202,7 @@ def phenotypes_data(conn: mdb.Connection,
                   f" LIMIT {limit} OFFSET {offset}" if bool(limit) else "")
     with conn.cursor(cursorclass=DictCursor) as cursor:
         cursor.execute(_query, (population_id, dataset_id))
-        debug_query(cursor)
+        debug_query(cursor, app.logger)
         return tuple(dict(row) for row in cursor.fetchall())
 
 
@@ -228,5 +229,5 @@ def save_new_dataset(cursor: Cursor,
         "%(created)s, %(public)s, %(population_id)s, %(confidentiality)s, "
         "%(users)s)",
         params)
-    debug_query(cursor)
+    debug_query(cursor, app.logger)
     return {**params, "Id": cursor.lastrowid}
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
index 02e8078..79aab81 100644
--- a/uploader/phenotypes/views.py
+++ b/uploader/phenotypes/views.py
@@ -8,6 +8,7 @@ from functools import wraps
 from redis import Redis
 from requests.models import Response
 from MySQLdb.cursors import DictCursor
+from gn_libs.mysqldb import database_connection
 from flask import (flash,
                    request,
                    url_for,
@@ -24,7 +25,6 @@ from uploader import jobs
 from uploader.files import save_file#, fullpath
 from uploader.oauth2.client import oauth2_post
 from uploader.authorisation import require_login
-from uploader.db_utils import database_connection
 from uploader.species.models import all_species, species_by_id
 from uploader.monadic_requests import make_either_error_handler
 from uploader.request_checks import with_species, with_population