14 May 18:42
Re: LIKE doesn't work in direct SQL queries
From: Michael Bayer <mike_mp <at> zzzcomputing.com>
Subject: Re: LIKE doesn't work in direct SQL queries
Newsgroups: gmane.comp.python.sqlalchemy.user
Date: 2008-05-14 16:42:14 GMT
Subject: Re: LIKE doesn't work in direct SQL queries
Newsgroups: gmane.comp.python.sqlalchemy.user
Date: 2008-05-14 16:42:14 GMT
try two percent signs to escape it - %%. On May 14, 2008, at 10:50 AM, Artur Siekielski wrote: > > Hi. > I want to execute ready SQL query using SA's engine: > >>>> engine.execute(r''' SELECT * FROM "City" WHERE name LIKE 'a%' ''') > > I get this strange error: > > /usr/share/python2.5/site-packages/SQLAlchemy-0.4.6dev_r4720- > py2.5.egg/ > sqlalchemy/engine/default.py in do_execute(self, cursor, statement, > parameters, context) > 128 > 129 def do_execute(self, cursor, statement, parameters, > context=None): > --> 130 cursor.execute(statement, parameters) > 131 > 132 def is_disconnect(self, e): > TypeError: 'dict' object is unindexable > > I'm using Python 2.5.2, PostgreSQL 8.3.1, psycopg2 2.0.7, SQLAlchemy > 0.4.5 and latest from trunk (0.4 branch). > What is not working is the percent sign: when I don't use them, > everything is OK. Underscores work. I suspect that it's an error in > psycopg2, which thinks that percents are for parameters. > > It's strange that such a simple thing doesn't work - or am I doing > something wrong? > > Regards, > Artur > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy <at> googlegroups.com To unsubscribe from this group, send email to sqlalchemy-unsubscribe <at> googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
RSS Feed