aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-10-16 14:43:33 +0300
committerFrederick Muriuki Muriithi2023-10-16 14:43:33 +0300
commit88e051bd31c491ffead08d4d4951945063835ab6 (patch)
treee295a4cca46de5a485af9115596e6fd5b36a5183 /scripts
parentc9af16ce37ccfbf75183ed0214e3a52a9d91dcc7 (diff)
downloadgn-uploader-88e051bd31c491ffead08d4d4951945063835ab6.tar.gz
Fix bug: parsing fields from query.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/insert_data.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/scripts/insert_data.py b/scripts/insert_data.py
index 7bf20f1..f273c3a 100644
--- a/scripts/insert_data.py
+++ b/scripts/insert_data.py
@@ -114,12 +114,11 @@ def __format_query__(query, params):
def __param_str__(param):
return "', '".join(str(elt) for elt in param)
idx = query.find("VALUES")
+ idx = query.find("%")
fields = tuple(
- elt.strip().replace("%(", "").replace(")s", "")
- for elt in query[idx + 7:-1].split(","))
- values = (
- tuple(param[field] for field in fields)
- for param in params)
+ elt.replace("%(", "").replace(")s", "").replace(")", "").strip()
+ for elt in query[idx:-1].split(","))
+ values = (tuple(param[field] for field in fields) for param in params)
values_str = ", ".join(
f"('{__param_str__(value_tup)}')" for value_tup in values)
insert_str = query[:idx].replace(