[Tutor] School Boy Error
John CORRY
john.corry at ntlworld.com
Sun Apr 16 00:48:36 CEST 2006
Thanks Brian for the help on the last one. I couldn't see the wood for
the trees. I have a tougher one for you.
I am reading in a CSV file. Each line represents a line that I want to
upload into my database. I am trying to upload the first line in the
file to get myself started. The code is below:-
import string, re
path = "c:/test/import.csv"
listy = []
input = file(path, "r")
for line in input.readlines():
line = line.split(",")
listy.append(line)
print listy[-1]
stat = """Insert into cost_grid values
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,)"""
t = 5000
d = "PF2"
b = 91.4
a = 95.00
import mx.ODBC
import mx.ODBC.Windows
db = mx.ODBC.Windows.DriverConnect('DSN=vfp')
c = db.cursor()
c.execute(stat, listy[-1])
db.commit()
c.close()
I get the following error:
TypeError: parameters must be a list of tuples
Any suggestions would be greatly appreciated.
Thanks,
John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060415/e0e08247/attachment.html
More information about the Tutor
mailing list