[DB-SIG] Some obscurity with paramstyle

Christoph Zwerschke cito at online.de
Mon Jul 18 14:25:03 CEST 2011


Am 18.07.2011 13:20 schrieb M.-A. Lemburg:
 > True. Some modules are also using %i and %f to bind
 > integers and floats.
 >
 >> So when writing a driver,
 >> do I need to support '%f' or not?
 >
 > The question is not whether you need to support them. You can
 > choose among the available formats. You don't need to support
 > all of them. One will do just fine.

Sorry, I was unclear. I meant *if* my driver advertizes itself with
paramstyle='format', does it need to support '%f' or does it suffice to
support '%s'? Same for 'pyformat'? From your answer above, it would need
to support '%f' as well. And does it also need to support flags, width,
precision, length modifiers such as '%.2f'?

My concrete problem was that I wanted to support Infinity and NaN where 
Postgres has a different spelling from Python and needs quotes. This is 
more difficult to implement if '%f' is allowed.

 > There are not a lot of Python 3 changes necessary and most of
 > the ones that are (like the exception base class StandardError
 > which then reads Exception) are obvious fixes.

But as Michael already pointed out, at least the unicode related issues 
are not so obvious. That was also the reason why WSGI needed a new PEP.

-- Christoph


More information about the DB-SIG mailing list