aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-03-22 07:30:34 +0300
committerFrederick Muriuki Muriithi2024-03-22 07:30:34 +0300
commit62e54fd5b457d67f3f01a35e28eae94d653d9908 (patch)
treee92d3684d908cac6d590905f05273ac998f815f4 /scripts
parent51b349d6acf11b2807b191c2b8e50d4315eb69b0 (diff)
downloadgn-uploader-62e54fd5b457d67f3f01a35e28eae94d653d9908.tar.gz
Notify user if identifiers are not consistent.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/insert_data.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/scripts/insert_data.py b/scripts/insert_data.py
index a60426a..5926905 100644
--- a/scripts/insert_data.py
+++ b/scripts/insert_data.py
@@ -290,12 +290,21 @@ def insert_se(# pylint: disable = [too-many-arguments]
read_datavalues(filepath, headings, strains).values()
for row in psrows))
with dbconn.cursor(cursorclass=DictCursor) as cursor:
- while True:
- serrors = tuple(take(se_values, 1000))
- if not bool(serrors):
- break
- print(__format_query__(se_query, serrors))
- cursor.executemany(se_query, serrors)
+ try:
+ while True:
+ serrors = tuple(take(se_values, 1000))
+ if not bool(serrors):
+ break
+ print(__format_query__(se_query, serrors))
+ cursor.executemany(se_query, serrors)
+ except KeyError as kerr:
+ print(
+ (
+ f"The following name(s) or identifier(s) do(es) not "
+ "exist in the database and did not exist in the original "
+ f"values file: {', '.join(kerr.args)}"),
+ file=sys.stderr)
+ return 1
return 0
if __name__ == "__main__":