mysql insert with tuple

Christian mining.facts at
Wed Nov 21 18:19:15 CET 2012

Hi ,

my purpose is a generic insert via  tuple , because the number of fields and can differ. But  I'm stucking .


#This version works, but all varchar fields are in extra '' enclosed.
con.execute(""" INSERT INTO {} VALUES %r; """.format(table) , (tuple(ilist),))

#This produce (1054, "Unknown column 'None' in 'field list'"),
#but without None values it works.
con.execute(""" INSERT INTO {} VALUES %r; """.format(table) % (tuple(ilist),))

Many thanks,

More information about the Python-list mailing list