From 8a84c4d6762446e5fdf9f9121f539c89419ae6a0 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 22 Nov 2024 12:16:28 -0600 Subject: Use gn-libs code for db connection. Use the code in gn-libs to connect to the database, rather than a local module. --- uploader/genotypes/models.py | 7 ++++--- uploader/genotypes/views.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'uploader/genotypes') diff --git a/uploader/genotypes/models.py b/uploader/genotypes/models.py index 44c98b1..4c3e634 100644 --- a/uploader/genotypes/models.py +++ b/uploader/genotypes/models.py @@ -4,8 +4,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 genocode_by_population( conn: mdb.Connection, population_id: int) -> tuple[dict, ...]: @@ -38,7 +39,7 @@ def genotype_markers( with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute(_query, (species_id,)) - debug_query(cursor) + debug_query(cursor, app.logger) return tuple(dict(row) for row in cursor.fetchall()) @@ -64,7 +65,7 @@ def genotype_dataset( with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute(_query, _params) - debug_query(cursor) + debug_query(cursor, app.logger) result = cursor.fetchone() if bool(result): return dict(result) diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index 0821eca..e6b1ba7 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -1,5 +1,6 @@ """Views for the genotypes.""" from MySQLdb.cursors import DictCursor +from gn_libs.mysqldb import database_connection from flask import (flash, request, url_for, @@ -11,7 +12,6 @@ from flask import (flash, from uploader.ui import make_template_renderer 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 -- cgit v1.2.3