diff --git a/bin/system_imports.py b/bin/system_imports.py index 925aa4d..1cd16a0 100755 --- a/bin/system_imports.py +++ b/bin/system_imports.py @@ -9,7 +9,7 @@ import os from glob import glob import configuration import preplots -from datastore import Datastore +from datastore import Datastore, psycopg2 exportables = [ "events_seq", @@ -38,11 +38,14 @@ if __name__ == '__main__': print("Survey does not define an export path for machine data") continue - for table in exportables: - path = os.path.join(pathPrefix, table) - print(" ← ", path, " → ", table) - with open(path, "rb") as fd: - cursor.copy_from(fd, table); + try: + for table in exportables: + path = os.path.join(pathPrefix, table) + print(" ← ", path, " → ", table) + with open(path, "rb") as fd: + cursor.copy_from(fd, table); + except psycopg2.errors.UniqueViolation: + print("It looks like data for this survey may have already been imported (unique constraint violation)") # If we don't commit the data does not actually get copied db.conn.commit()