daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Nov 9th, 2012 33 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
Top