python/mysql/list question...

bruce bedouglas at earthlink.net
Thu Aug 10 21:37:20 EDT 2006


hi.

i have the following sample code. i'm trying to figure out if there's a way
to use a 'list of lists' in a mysql execute...

i've tried a variety of combinations but i get an error:
 Error 1241: Operand should contain 1 column(s)

the test code is:

insertSQL = """insert into appTBL
             (appName, universityID)
              values(%s,%s)"""

a = []
b = []
a.append('qqa')
a.append(222)
b.append(a)
a=[]
a.append('bbb')
a.append(66)
b.append(a)

try:
  c.execute(insertSQL, (b[0],b[1]))  <<<<<<<<<<<<<<<<<<<
except MySQLdb.Error, e:
  print "Error %d: %s" % (e.args[0], e.args[1])
  print b
  sys.exit (1)

i've tried to use b, (b), etc...
using b[0] works for the 1st row...


any thoughts/comments...

thanks





More information about the Python-list mailing list