[Bug 712137] Re: executemany fails when passing a list of dicts

dino99 712137 at bugs.launchpad.net
Fri Aug 28 09:55:32 UTC 2015


This version has expired

** Changed in: python-mysqldb (Ubuntu)
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python-mysqldb in Ubuntu.
https://bugs.launchpad.net/bugs/712137

Title:
  executemany fails when passing a list of dicts

Status in python-mysqldb package in Ubuntu:
  Invalid

Bug description:
  Binary package hint: python-mysqldb

  using the table:
  --------------------
  create table a(f1 int, f2 int);

  and the python code:
  ---------------------------

  import MySQLdb

  conn = MySQLdb.connect('localhost','root','root','test')
  cursor = conn.cursor()

  vals = [{'f1' : 1, 'f2' : 2}]
  sql = "insert into a values (%(f1)s, %(f2)s)"

  print MySQLdb.__version__
  cursor.execute(sql, vals[0])
  print "execute works"
  cursor.executemany(sql, vals)
  print "execute many works"

  gives the result:
  --------------------

  1.2.2
  execute works
  Traceback (most recent call last):
    File "test.py", line 11, in <module>
      cursor.executemany(sql, vals)
    File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 217, in executemany
      self.errorhandler(self, exc, value)
    File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35, in defaulterrorhandler
      raise errorclass, errorvalue
  ValueError: incomplete format

  but should give:
  --------------------

  1.2.2
  execute works
  execute many works

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-mysqldb/+bug/712137/+subscriptions



More information about the foundations-bugs mailing list