loc = sys.argv[3] if os.path.isfile(loc): logs = logparse.parse_file(loc) else: logs = logparse.parse_dir(loc) logs_filtered = logs[start:stop] prev = None exceptCount = 0 prematureBreak = False for line in logs_filtered: if not prev is None: try: sid.feed(prev[1],line[1]) exceptCount = 0 prev = line except KeyboardInterrupt: sys.exit(0) except Exception as e: print(e) print("(On log line {})".format(line[2])) prev = None exceptCount += 1 if exceptCount >= EXCEPTION_LIMIT: prematureBreak = True break else: prev = line
import sentence_into_db as sid import sqlite3 import db """ db = sqlite3.connect(":memory:") db.execute("CREATE TABLE bla (foo int)") db.execute("INSERT INTO bla (foo) VALUES (?)", (None,)) """ sid.feed("I am awesome.", "Yes you are.") db.conn.commit() db.conn.close()