2015-02-17 06:58:11 +01:00
|
|
|
import sys
|
|
|
|
import csv
|
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
if len(sys.argv) < 3:
|
2015-05-17 11:49:35 +02:00
|
|
|
print("Use: {0} DATABASE_NAME TABLE_NAME".format(sys.argv[0]))
|
2015-02-17 06:58:11 +01:00
|
|
|
exit()
|
|
|
|
|
|
|
|
conn = sqlite3.connect(sys.argv[1])
|
|
|
|
cur = conn.cursor()
|
|
|
|
data = cur.execute("SELECT * FROM {0}".format(sys.argv[2]))
|
|
|
|
|
|
|
|
with open('output.csv', 'wb') as f:
|
|
|
|
writer = csv.writer(f)
|
|
|
|
writer.writerows(data)
|
|
|
|
|
|
|
|
conn.close()
|