Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: MySQLdb compare lower

Reply
Thread Tools

Re: MySQLdb compare lower

 
 
Frank Millman
Guest
Posts: n/a
 
      12-14-2012
On 14/12/2012 06:16, Chris Angelico wrote:
>
> Yeah, it's one of the things that tripped me up when I did a
> MySQL->PostgreSQL conversion earlier this year. The code was assuming
> case insensitivity, and began failing on PG. Fortunately the simple
> change of LIKE to ILIKE solved that.
>
> I'd MUCH rather be explicit about wanting case insensitivity.


Just as a side-note, for those who may be interested -

PostgreSQL allows you to create an index using an expression.

Therefore you can say -

CREATE INDEX ndx ON table_name (LOWER(col_name))

Then you can SELECT ... WHERE LOWER(col_name) = LOWER(%s), and it will
use the index, so it is not necessary to coerce the data to lower case
before storing.

Frank Millman


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: MySQLdb compare lower Dennis Lee Bieber Python 0 12-13-2012 11:39 PM
Re: MySQLdb compare lower Cameron Simpson Python 0 12-13-2012 07:00 AM
Re: MySQLdb compare lower Dennis Lee Bieber Python 0 12-12-2012 07:03 AM
Re: MySQLdb compare lower Cameron Simpson Python 0 12-11-2012 10:43 PM
MySQLdb compare lower Anatoli Hristov Python 2 12-11-2012 10:39 PM



Advertisments