Python/MySQL Frustration

Victor Subervi victorsubervi at gmail.com
Sun Sep 20 14:25:53 EDT 2009


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
Now, all of this posts to the mysql database, but it forms an infinite loop!
I have num == 1! I have printed num to make sure it's actually only 1 (or 2,
depending). What in the heck am I doing wrong?
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090920/14c74822/attachment.html>


More information about the Python-list mailing list