Skip site navigation (1) Skip section navigation (2)

Re: Problem with index using regular expression

From: Alejandro Dubrovsky <alex(dot)dubrovsky(at)hitwise(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Re: Problem with index using regular expression
Date: 2011-06-06 07:10:18
Message-ID: 4DEC7D5A.9020005@hitwise.com (view raw or flat)
Thread:
Lists: psycopg
On 06/06/11 17:07, Federico Di Gregorio wrote:
> On 06/06/11 09:03, Håvard Wahl Kongsgård wrote:
>> substring(nodes.name <http://nodes.name> from
>> E'\\w.*\\s(\\w.*)$|\\w+\\s(\\w.*)$') = substring(income.name
>> <http://income.name> from E'\\w.*\\s(\\w.*)$|\\w+\\s(\\w.*)$') limit 1000")
> 
> Try doubling every '\' because that's a Python escape character too and
> you want to send to the database the "\\X" sequence, not "\X"; i.e.,
> 
> ... from E'\\\\w.*\\\\s(\\\\w.*)$|\\\\w+\\\\s(\\\\w.*)$') ...
> 
It's easier to just put an r at the front of the string.
ie
r"SELECT Distinct On (nodes.id) nodes.ID from nodes inner join income on
substring(nodes.name from E'\\w.*\\s(\\w.*)$|\\w+\\s(\\w.*)$') =
substring(income.name from E'\\w.*\\s(\\w.*)$|\\w+\\s(\\w.*)$') limit 1000"




In response to

Responses

psycopg by date

Next:From: Håvard Wahl KongsgårdDate: 2011-06-06 08:01:36
Subject: Re: Problem with index using regular expression
Previous:From: Federico Di GregorioDate: 2011-06-06 07:07:50
Subject: Re: Problem with index using regular expression

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group