On Jul 30, 2007, at 2:11 AM, yish wrote:
> > Hi, I decided to explore Pylons and was going through the QuickView > tutorial when I came across a problem. > > I am getting the following exception: > > page = model.Page.get_by(title=u'FrontPage') > Traceback (most recent call last): > .... > "SQLError: (ProgrammingError) ERROR: column "frontpage" does not > exist > > SELECT pages.content AS pages_content, pages.title AS pages_title > FROM pages > WHERE pages.title = FrontPage ORDER BY pages.title > LIMIT 1 'SELECT pages.content AS pages_content, pages.title AS > pages_title \nFROM pages \nWHERE pages.title = %(pages_title)s ORDER > BY pages.title \n LIMIT 1' {'pages_title': u'FrontPage'}" > > It looked to me that the sql query was not being properly generated. > The "FrontPage" within the query should be escaped with single quotes, > e.g: > SELECT pages.content AS pages_content, pages.title AS pages_title > FROM pages > WHERE pages.title = 'FrontPage' ORDER BY pages.title > LIMIT 1 > > After trying the same query with "title" not defined as unicode i have > no problems, e,g: > page = model.Page.get_by(title='FrontPage') > succeeds perfectly. > > Is this the expected unicode behavior for sqlalchemy? yes. we dont "quote" or "escape" query arguments, we use bind parameters as you can see in %(pages_title)s. Also, to indicate that you'd like SQLAlchemy to convert unicode bind parameters to strings, for compatibility with database APIs which don't accept unicode strings (such as psycopg2), use the "convert_unicode=True" flag sent to create_engine(). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---