A SQLObject case insensitive LIKE query

SQLObject is:

…a popular Object Relational Manager for providing an object interface to your database, with tables as classes, rows as instances, and columns as attributes.

SQLObject includes a Python-object-based query language that makes SQL more abstract, and provides substantial database independence for applications.


I’ve been reading through the SQLObject documentation and it’s not always clear when it comes to executing a LIKE query and a bit of Googling turned up a number of related questions therefore I thought I’d contribute this tiny bit of knowledge to the Intertubes. In my case I want to perform a case insensitive LIKE query and here’s one means of performing this sort of query via SQLObject:

MyTable.select(sqlobject.LIKE(func.lower(MyTable.q.url), func.lower('')))

That equates to this SQL:

SELECT MyTable.field1 FROM MyTable WHERE (lower(MyTable.url) LIKE (lower('')))

In the above example “func.lower” is SQLObject’s syntax for indicating the SQL server’s lowercase function should be used.