Skip to content

Commit 25e5b3a

Browse files
committed
basic sql2csv
1 parent 0523b16 commit 25e5b3a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

‎24_sql2csv.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
importsys
2+
importcsv
3+
importsqlite3
4+
5+
iflen(sys.argv) <3:
6+
print"Use:{0} DATABASE_NAME TABLE_NAME".format(sys.argv[0])
7+
exit()
8+
9+
conn=sqlite3.connect(sys.argv[1])
10+
cur=conn.cursor()
11+
data=cur.execute("SELECT * FROM{0}".format(sys.argv[2]))
12+
13+
withopen('output.csv', 'wb') asf:
14+
writer=csv.writer(f)
15+
writer.writerows(data)
16+
17+
conn.close()

‎readme.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
1.**20_restore_file_from_git.py**: Restore file from Git History
2323
1.**21_twitter_bot.py**: Twitter Bot
2424
1.**22_git_tag.py**: Create Git Tag based on a commit
25-
1.**23_flask_session_test.py**: Just a simple app to see if the sessions are working.
25+
1.**23_flask_session_test.py**: Just a simple app to see if the sessions are working
26+
1.**24_sql2csv.py**: SQL to CSV.

0 commit comments

Comments
(0)