pyformat / other named parameters broken

Bug #454790 reported by Mike Bayer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Connector/Python
Fix Released
Medium
Geert JM Vanderkelen

Bug Description

MySQL connector returns "pyformat" for the value of "paramstyle", however the execute() method does not accept mapping objects, only sequences, raising the error "Parameters must be given as a sequence.". The "format" style, which is positional, works fine.

MySQL connector should either support mappings as well as sequences for the execute() and executemany() methods, or it should not advertise a named parameter style as the value of "paramstyle".

Test case is attached.

Tags: cursor pep249
Revision history for this message
Mike Bayer (zzzeek) wrote :
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

Thanks for reporting this! This is something I actually totally forgot as I am more using positional.
We'll be fixing this.

Changed in myconnpy:
assignee: nobody → Geert JM Vanderkelen (geertjmvdk)
importance: Undecided → Medium
status: New → Confirmed
tags: added: cursor pep249
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

Fix has been committed (revision 115).
This works:
  c.execute("SELECT %(name)s,%(year)s", {'name': 'Geert','year':1977})
  c.executemany("SELECT %(name)s,%(year)s", [{'name': 'Geert','year':1977},{'name':'Marta','year':1980}])

So we now support 'format' and 'pyformat'.

Changed in myconnpy:
status: Confirmed → Fix Committed
Changed in myconnpy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.