Rich Shepard wrote:
  If I have a string variable with 31 fields (integer, text, text, and 28
floats), and the values are separated by commas (and quotes for the text),
can I insert them into the appropriate table with a single statement such
as this from a python/pysqlite method I'm writing:

self.cur.execute("insert into component(vote_id, cat, pos, pw) values (row)")


Rich,

Not as shown, but you could build the insert statement as a string in python and then pass that to the execute method. Assuming row is your string of values:

sql = "insert into component(vote_id, cat, pos, pw) values (" + row + ")"
self.cur.execute(sql)

Note, you have only got 4 columns in your column list, so you will get an error if you feed in 31 columns of data.

You may need to extract the relevant columns using split to separate your string at the commas, collecting the data for the columns you need, and then reassembling only those columns into a new string of row data.

HTH
Dennis Cote

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to