Dennis Lee Bieber wrote:
On Sun, 20 Sep 2009 14:25:53 -0400, Victor Subervi
<victorsube...@gmail.com> declaimed the following in
gmane.comp.python.general:

Hi;
I have the following code:

     while i < num:
      cat = 'cat' + str(i)
      cat = form.getfirst(cat, '')
      item = 'item' + str(i)
      item = form.getfirst(item, '')
      descr = 'descr' + str(i)
      descr = form.getfirst(descr, '')
      uom = 'uom' + str(i)
      uom = form.getfirst(uom, '')
      price = 'price' + str(i)
      price = form.getfirst(price, '')
      sql = 'Category="' + cat + '", Item="' + item + '", Description="' +
descr + '", UOM="' + uom + '", Price="' + price + '"'
      sql = 'insert into %s values (%s);' % (company, sql)
      cursor.execute(sql)
      i += 1

        Forgive me, but that is a bit of a mess... And from what I can see,
does not even generate valid insert statements unless MySQL has expanded
the syntax greatly.

    You're probably throwing an exception at "cursor.execute".  Are you catching
exceptions somewhere else?

    Also, you need to call "commit()" when you're done updating, or, at program
exit, all your changes to the database will be undone, at least if you're using
any of the database engines that do transactions.

                                        John Nagle
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to