Re: [sqlalchemy] Running an externally supplied SQL statement with special characters

2013-11-29 Thread Ivan Kalinin
Actually, using the session.connection().execute did help! Also, I think there is an option of creating a TextClause subclass with a different search regex that, for example, matches nothing. But it's a bit of an overkill, IMO. On Fri, Nov 29, 2013 at 10:41 PM, Michael Bayer

Re: [sqlalchemy] Running an externally supplied SQL statement with special characters

2013-11-29 Thread Michael Bayer
yes, that workaround works, but much more simply, using a backslash in text() should work as well On Nov 29, 2013, at 2:01 PM, Ivan Kalinin pupss...@gmail.com wrote: Actually, using the session.connection().execute did help! Also, I think there is an option of creating a TextClause

Re: [sqlalchemy] Running an externally supplied SQL statement with special characters

2013-11-29 Thread Ivan Kalinin
The point is we get those SQL statements from an external source and we'd prefer not to modify them. I do understand its a rare use-case of SA, but having a DumbTextClause or an option regex parameter in TextClause constructor could help. On Fri, Nov 29, 2013 at 11:06 PM, Michael Bayer

Re: [sqlalchemy] Running an externally supplied SQL statement with special characters

2013-11-29 Thread Michael Bayer
if you’re using the text() constructor directly anyway, you can just define a helper like this: def unescaped_text(sql): return text(sql.sub(‘:’, ‘\\:’)) On Nov 29, 2013, at 2:15 PM, Ivan Kalinin pupss...@gmail.com wrote: The point is we get those SQL statements from an external source

[sqlalchemy] Running an externally supplied SQL statement with special characters

2013-11-22 Thread Ivan Kalinin
Hello there, fellow developers! We've recently run into a terrible problem. A small tool uses SQLAlchemy to execute statements read from a text file against a database. The trouble comes when that pre-defined statement has a colon symbol in the field value of a, say, INSERT statement. Like

Re: [sqlalchemy] Running an externally supplied SQL statement with special characters

2013-11-22 Thread Michael Bayer
On Nov 22, 2013, at 1:11 PM, Ivan Kalinin pupss...@gmail.com wrote: Hello there, fellow developers! We've recently run into a terrible problem. A small tool uses SQLAlchemy to execute statements read from a text file against a database. The trouble comes when that pre-defined