about summary refs log tree commit diff
path: root/uploader
diff options
context:
space:
mode:
Diffstat (limited to 'uploader')
-rw-r--r--uploader/phenotypes/models.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index e217699..498a48b 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -295,7 +295,11 @@ def create_new_phenotypes(conn: mdb.Connection,
     """Add entirely new phenotypes to the database."""
     _phenos = tuple()
     with conn.cursor(cursorclass=DictCursor) as cursor:
-        for batch in take(phenotypes, 1000):
+        while True:
+            batch = take(phenotypes, 1000)
+            if len(batch) == 0:
+                break
+
             cursor.executemany(
                 ("INSERT INTO "
                  "Phenotypes(Pre_publication_description, Original_description, Units, Authorized_Users) "
@@ -325,7 +329,12 @@ def save_phenotypes_data(
     }[table]
     saved_data = tuple()
     with conn.cursor(cursorclass=DictCursor) as cursor:
-        for batch in take(data, 5000):
+        while True:
+            batch = take(data, 5000):
+            if len(batch) == 0:
+                logger.warning("Got an empty batch. This needs investigation.")
+                break
+
             cursor.executemany(
                 (f"INSERT INTO {_table_details['table']}"
                  f"(Id, StrainId, {_table_details['valueCol']}) "