Commit database changes every 100 e-mails

master
Sven Slootweg 13 years ago
parent 37c1fc0bdb
commit 1bc6105085

10
parse

@ -84,6 +84,8 @@ except sqlite3.OperationalError:
# Select all files matching the given pattern
file_list = glob.glob(options['pattern'])
finished = 0
for email_file in file_list:
message = email.message_from_file(open(email_file, 'r'))
@ -170,5 +172,11 @@ for email_file in file_list:
if inserted > 0:
print "Successfully inserted %d attachment(s) for %s." % (inserted, sha1_hash)
finished += 1
if finished % 100 == 0:
database.commit()
print "%d e-mails done, commited changes to database." % finished
database.commit()
print "Changes successfully committed to database."
print "Changes successfully committed to database, all done."

Loading…
Cancel
Save