Do not hard fail if imports fail for one project.

It may be the case that we have already re-imported
some of the data, so we just move on to the next
project.
This commit is contained in:
D. Berge
2020-09-23 15:46:17 +02:00
parent 6bab21bce4
commit 97104556b7

View File

@@ -9,7 +9,7 @@ import os
from glob import glob from glob import glob
import configuration import configuration
import preplots import preplots
from datastore import Datastore from datastore import Datastore, psycopg2
exportables = [ exportables = [
"events_seq", "events_seq",
@@ -38,11 +38,14 @@ if __name__ == '__main__':
print("Survey does not define an export path for machine data") print("Survey does not define an export path for machine data")
continue continue
for table in exportables: try:
path = os.path.join(pathPrefix, table) for table in exportables:
print("", path, "", table) path = os.path.join(pathPrefix, table)
with open(path, "rb") as fd: print("", path, "", table)
cursor.copy_from(fd, 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 # If we don't commit the data does not actually get copied
db.conn.commit() db.conn.commit()