I haven't been entirely following along with what you and Mike have been 
talking about, but one final suggestion: If your problem is something to with 
LIKE only working in one direction, you could always do the first filter in the 
query, and then filter those results in the other direction in Python. Again, 
the quantity of data might prohibit this, but just a thought.


-----Original Message-----
From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On 
Behalf Of yannack
Sent: Thursday, 9 February 2012 2:03 AM
To: sqlalchemy
Subject: [sqlalchemy] Re: String matching

Great, thanks for this, I will definitely play around with this.
Lots of great tools and links here!
However, I do have a remark for Mike:
you suggest
('%' + literal(custom_string) + '%').ilike('%' + MyClass.column +
'%')
While this probably works for PGSQL (haven't tested though), in sqlite
it won't, as in sqlite
'%AA%' like 'XAAX'
isn't True, but:
'XAAX' like '%AA%'
is True.
At least where I am, the '%' symbol only works on the right hand side
of "LIKE" not on the left.
This is why I had to do the trick with or_ in my code.
Again, thanks for this answer Michael!

To Cameron Jackson: my database is quite large, which is why I wan't
to avoid python matching. Your solution, while it may work on small
instances, is not suited for my particular use case. I try to avoid
querying the entire database in memory before working on it as a
general rule. Thanks anyways though !

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



-------------------------------------------------------------------------
DISCLAIMER: This e-mail transmission and any documents, files and 
previous e-mail messages attached to it are private and confidential.  
They may contain proprietary or copyright material or information that 
is subject to legal professional privilege.  They are for the use of 
the intended recipient only.  Any unauthorised viewing, use, disclosure, 
copying, alteration, storage or distribution of, or reliance on, this 
message is strictly prohibited.  No part may be reproduced, adapted or 
transmitted without the written permission of the owner.  If you have 
received this transmission in error, or are not an authorised recipient, 
please immediately notify the sender by return email, delete this 
message and all copies from your e-mail system, and destroy any printed 
copies.  Receipt by anyone other than the intended recipient should not 
be deemed a waiver of any privilege or protection.  Thales Australia 
does not warrant or represent that this e-mail or any documents, files 
and previous e-mail messages attached are error or virus free.  

-------------------------------------------------------------------------

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to