aboutsummaryrefslogtreecommitdiff
path: root/uploader
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-03 16:22:51 -0500
committerFrederick Muriuki Muriithi2024-09-03 16:51:27 -0500
commit4f0d75c94ca1acf0217990d67092f8a72a9cdef1 (patch)
tree648871b3ad51ac6d4643e69de068c6b4c7c35b23 /uploader
parent384d5205bf64cb769642800a82208369f1cd9a0e (diff)
downloadgn-uploader-4f0d75c94ca1acf0217990d67092f8a72a9cdef1.tar.gz
Provide means to debug actual query run and params used.
Diffstat (limited to 'uploader')
-rw-r--r--uploader/db_utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/uploader/db_utils.py b/uploader/db_utils.py
index 5b79762..d31e2c2 100644
--- a/uploader/db_utils.py
+++ b/uploader/db_utils.py
@@ -7,6 +7,7 @@ from typing import Any, Tuple, Iterator, Callable
import MySQLdb as mdb
from redis import Redis
+from MySQLdb.cursors import Cursor
from flask import current_app as app
def parse_db_url(db_url) -> Tuple:
@@ -43,3 +44,11 @@ def with_redis_connection(func: Callable[[Redis], Any]) -> Any:
redisuri = app.config["REDIS_URL"]
with Redis.from_url(redisuri, decode_responses=True) as rconn:
return func(rconn)
+
+
+def debug_query(cursor: Cursor):
+ """Debug the actual query run with MySQLdb"""
+ for attr in ("_executed", "statement", "_last_executed"):
+ if hasattr(cursor, attr):
+ logging.debug("MySQLdb QUERY: %s", getattr(cursor, attr))
+ break