123456789101112131415161718192021 |
- #!/usr/bin/env python3
- import sys
- import sqlite3
- if len(sys.argv) < 3:
- print("Usage: <database > <fortune file>")
- sys.exit(1)
- con = sqlite3.connect(sys.argv[1])
- cur = con.cursor()
- with open(sys.argv[2]) as fp:
- lines = fp.readlines()
- for line in lines:
- print(line)
- cur.execute("INSERT INTO mean VALUES (?)", (line,))
- con.commit()
- sys.exit(0)
|