This project is archived and is in readonly mode.
Problem with %, (, ) in names of parameters in cursor.execute
-
Daniele Varrazzo
- State changed from new to open
I don't know about
%, but(and)don't work in Python either.%works in Python but not in psycopg: I'll have to check why.I think the only fix you may end up with is to just have
%accepted inside the parenthesis, with no need to escape, while(and `) won't be accepted.In [4]: print "foo %(50%)s baz" % {'50%': 'bar'} foo bar baz In [5]: cur.mogrify("foo %(50%)s baz", {'50%': 'bar'}) --------------------------------------------------------------------------- ProgrammingError Traceback (most recent call last) /home/piro/dev/psycopg2/build/lib.2.7/<ipython-input-5-71c53d1f4f43> in <module>() ----> 1 cur.mogrify("foo %(50%)s baz", {'50%': 'bar'}) ProgrammingError: incomplete placeholder: '%(' without ')'I don't want to diverge from what Python's
%accepts and complicate something as easy as the name of the parameters with escaping rules. -
Daniele Varrazzo
- State changed from open to resolved
Issue solved by declaring in the docs that %, (, ) are not supported.