aboutsummaryrefslogtreecommitdiff
path: root/uploader
diff options
context:
space:
mode:
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