Advertisement
Guest User

Untitled

a guest
Nov 9th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1.  
  2. #import data to sqlite db test.db
  3. import sqlite3 as lite
  4. import sys
  5.  
  6.  
  7. con = lite.connect('test.db')
  8. with con:
  9. cur = con.cursor()
  10. cur.executescript('drop table if exists Names;')
  11. cur.execute("CREATE TABLE Names(Id INT PRIMARY KEY, Name TEXT);")
  12. with open('file.txt') as f:
  13. for line in f:
  14. line.strip()
  15. print line
  16. cur.execute('INSERT INTO Names(Name) VALUES(?)', line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement