Skip to content

Commit 7bee481

Browse files
committed
Account for error while reading a row.
1 parent 2ad5f54 commit 7bee481

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

data_processing/dbmerge.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,19 @@ def merge(db_files=None, out_file=None, overwrite=False, attempt_salvage=True):
7878
try:
7979
for row in cursor:
8080
id, name, device, uuid, created = row
81-
except IndexError:
81+
except (sqlite3.OperationalError,sqlite3.DatabaseError,IndexError):
8282
print "No file info exists in: " + db_file
8383
continue
8484
print "Processing %s" % db_file
85-
cursor.execute("select * from %s" % data_table)
86-
for row in cursor:
87-
id, probe, timestamp, value = row
88-
new_row = (('%s-%d' % (uuid, id)), device, probe, timestamp, value)
89-
out_conn.execute("insert into data values (?, ?, ?, ?, ?)", new_row)
85+
try:
86+
cursor.execute("select * from %s" % data_table)
87+
for row in cursor:
88+
id, probe, timestamp, value = row
89+
new_row = (('%s-%d' % (uuid, id)), device, probe, timestamp, value)
90+
out_conn.execute("insert into data values (?, ?, ?, ?, ?)", new_row)
91+
except (sqlite3.OperationalError,sqlite3.DatabaseError,IndexError):
92+
print "Error processing the remainder of the file in: " + db_file
93+
continue
9094
out_conn.commit()
9195
out_cursor.close()
9296

0 commit comments

Comments
 (0)