From 1bc6105085d05bb08998b537983f333989d5bd0d Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Mon, 28 May 2012 02:36:54 +0200 Subject: [PATCH] Commit database changes every 100 e-mails --- parse | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/parse b/parse index 0512217..fe4a73e 100755 --- a/parse +++ b/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."