basic sql2csv
This commit is contained in:
parent
0523b16f80
commit
25e5b3a8d0
17
24_sql2csv.py
Normal file
17
24_sql2csv.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import sys
|
||||||
|
import csv
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
|
if len(sys.argv) < 3:
|
||||||
|
print "Use: {0} DATABASE_NAME TABLE_NAME".format(sys.argv[0])
|
||||||
|
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()
|
@ -22,4 +22,5 @@
|
|||||||
1. **20_restore_file_from_git.py**: Restore file from Git History
|
1. **20_restore_file_from_git.py**: Restore file from Git History
|
||||||
1. **21_twitter_bot.py**: Twitter Bot
|
1. **21_twitter_bot.py**: Twitter Bot
|
||||||
1. **22_git_tag.py**: Create Git Tag based on a commit
|
1. **22_git_tag.py**: Create Git Tag based on a commit
|
||||||
1. **23_flask_session_test.py**: Just a simple app to see if the sessions are working.
|
1. **23_flask_session_test.py**: Just a simple app to see if the sessions are working
|
||||||
|
1. **24_sql2csv.py**: SQL to CSV.
|
Loading…
Reference in New Issue
Block a user