Thread: [SQLObject] Select suing regular expressions
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Sherman L. <she...@st...> - 2006-05-09 16:06:01
|
Hello, I'm a newbie to SQLObject and I have a simple problem. I have a postgres database in which I store a search key in which I need to do a select using a regular expression. The resulting sql needs to look like this: SELECT * FROM indices WHERE search_key ~ '^x2x[0-9]{1,2}z' ORDER BY id; Using SQLObject how can I change the default "=" operator to "~" to get the proper sequal? I don't mind over riding something (the Select I assume) for this one db specific select, and then having the system dependent on the db used. Is there a clean way to do this? TIA Sherman -- Sherman Lambert She...@st... Colorado State Public Defenders Office --That justice escape none! |
From: Oleg B. <ph...@ma...> - 2006-05-09 16:13:47
|
On Tue, May 09, 2006 at 10:05:46AM -0600, Sherman Lambert wrote: > SELECT * > FROM indices > WHERE search_key ~ '^x2x[0-9]{1,2}z' > ORDER BY id; from sqlobject.sqlbuilder import RLIKE Indices.select(RLIKE(Indices.q.searchKey, '^x2x[0-9]{1,2}z')) RLIKE has been added to SQLObject after 0.7 so you have to download SQLObject from SVN or use my unofficial tarballs. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |