diff options
-rw-r--r-- | scripts/insert_data.py | 9 |
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( |