Re: psycopg2 gets confused by % characters and strict pyformat mode
Alejandro Dubrovsky <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2008-09-10 at 17:43 +0800, James Henstridge wrote: > On Wed, Sep 10, 2008 at 5:31 PM, Federico Di Gregorio <fog-NGVKUo/i/[email protected]> wrote: > > Il giorno mer, 10/09/2008 alle 18.13 +1000, Alejandro Dubrovsky ha > > scritto: > >> Is there a way to force psycopg2 to only take into account pyformat > >> variables and to leave the other %'s alone? If not, would you accept a > >> patch to do this? > > > > Currently there is no way. A patch would be welcome. > > Isn't that likely to break existing applications that depend on the > current behaviour? From what I can see, the current behaviour when > parameters are passed matches the DB-API specification. > > It is debatable whether the behaviour when no parameters are passed is > correct (should it parse the '%' signs in that case?), but this > proposal seem to move things further away. > My suggestion was to have a settable mode whereby strings like '%s' are ignored, and only %(these)s are taken into account. eg pyscopg2.paramstylestrict = True Default behaviour would remain unchanged.