format exception with DDL statements
Issue #1267
resolved
Executing a literal DDL statement causes formatting exception:
>>> from sqlalchemy import *
>>> e = create_engine('sqlite://')
>>> DDL("SELECT '%'").execute(e)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python25\lib\site-packages\sqlalchemy-0.5.0rc4-py2.5.egg\sqlalchemy\schema.py", line 1910, in execute
executable = expression.text(self._expand(schema_item, bind))
File "c:\python25\lib\site-packages\sqlalchemy-0.5.0rc4-py2.5.egg\sqlalchemy\schema.py", line 1995, in _expand
return self.statement % self._prepare_context(schema_item, bind)
ValueError: unsupported format character ''' (0x27) at index 9
For some context, I ran into this problem when attempting to create a pl/python function in PG.
Comments (3)
-
repo owner -
repo owner - changed status to resolved
OK this escapes automatically in 5bc1f17cb53248e7cea609693a3b2a9bb702545b
-
repo owner - removed milestone
Removing milestone: 0.5.0 (automated comment)
- Log in to comment
you need to escape % signs in postgres as in '%%'. we haven't decided yet to automatically perform this escaping in the text() construct but this would be an 0.5 only change.