On Mon, 11 Sep 2006, Dennis Cote wrote:

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)

Dennis,

  Yes, 'row' is the string of values.

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.

  I've corrected this already.

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.

  This is what I thought that I did for the first three fields (a sequential
record ID that relates the digital record to a paper form), and the two text
fields. Those are inserted in individual statements. I wasn't at all clear
about the rest of the values; that's why I asked.

  The statement now reads:

# now get the pair-wise vote values for rows 7-34, bytes 12-67, with
dictionary lookups
pw = split_line[7:67:2]
self.cur.execute("insert into voting(pr1, pr2, pr3, pr4, \
        pr5, pr6, pr7, pr8, pr9, pr10, pr11, pr12, pr13, pr14, pr15, \
        pr16, pr17, pr18, pr19, pr20, pr21, pr22, pr23, pr24, pr25, \
        pr26, pr27, pr28) values (DATA_MAP_7(pw))")

  If I understand your revision, I need to change the end of the above
statement to values (DATA_MAP_7(" + pw + "). Does this look better?

  I'll make up a test case and try it from within ipython. Also, I just
ordered the Apress SQLite book.

Thanks,

Rich

--
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863

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

Reply via email to