Skip to content

Instantly share code, notes, and snippets.

@hirolovesbeer
Created February 15, 2017 09:30
Show Gist options
  • Save hirolovesbeer/d35dcd17205975823f1da6fc24f39fb4 to your computer and use it in GitHub Desktop.
Save hirolovesbeer/d35dcd17205975823f1da6fc24f39fb4 to your computer and use it in GitHub Desktop.
import os.path
import sqlite3
db_file = 'test2.db'
if not os.path.exists(db_file):
conn = sqlite3.connect(db_file)
conn.execute("create virtual table syslog using fts3(logs)");
conn = sqlite3.connect(db_file)
with open("20k.log") as fh:
for line in fh:
# print(line)
line = line.replace("'", "''")
sql = "insert into syslog values('" + line + "')"
# print(sql)
conn.execute(sql)
# conn.commit()
conn.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment