Commit database changes every 100 e-mails
This commit is contained in:
parent
37c1fc0bdb
commit
1bc6105085
10
parse
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'))
|
||||
|
||||
|
@ -169,6 +171,12 @@ 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…
Reference in a new issue