importing csv file into sqlite
klia
alwaseem307ster at yahoo.com
Thu Dec 18 02:20:15 EST 2008
klia wrote:
>
> hey guys, i have a hug .csv file which i need to insert it into sqlite
> database using python.
> my csv data looks like this
> Birthday2,12/5/2008,HTC,this is my birthday
> Sea,12/3/2008,kodak,sea
> birthday4,14/3/2009,samsung,birthday
> love,17/4/2009,SONY,view of island
>
> can any one give me a head start codes.
>
> thanks in advance
>
guys so far i came out with this but i get this error
waseem at Linux:~/Project2$ python experment.py
Traceback (most recent call last):
File "experment.py", line 13, in <module>
curse.execute('INSERT INTO photos VALUES (?,?,?,?)',item)
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current
statement uses 4, and there are 1 supplied.
here's the codes
import sqlite3
import csv
f = open('/home/waseem/Project2/photos.txt')
csv.field_size_limit(100000) #see below!
input = csv.reader(f, delimiter='\t')
conn = sqlite3.connect('/home/waseem/Project2/picutres.db')
curse = conn.cursor()
curse.execute('CREATE TABLE photos (Name VARCHAR(100) PRIMARY KEY, Date
INTEGER, Make VARCHAR(50), Tag VARCHAR(100))')
for item in input:
curse.execute('INSERT INTO photos VALUES (?,?,?,?)',item)
curse.commit()
--
View this message in context: http://www.nabble.com/importing-csv-file-into-sqlite-tp21067453p21068111.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list
mailing list