sqlite user-defined functions & unicode issue

B

Ben Wolfson

I've got a db some of whose elements have been created automatically
from filesystem data (whose encoding is iso-8859-1). If I try to
select one of those elements using a standard SQL construct, things
work fine:
Butcher%",)).fetchall()
[(1653, u'John Butcher & Eddie Pr\xe9vost')]
But if I use the pysqlite recipe for searching with a regexp, things don't work:('John Butcher',)).fetchall()

Traceback (most recent call last):
File "<pyshell#14>", line 1, in -toplevel-
cursor.execute("SELECT * FROM artists WHERE REGEXP(?, name)",
('John Butcher',)).fetchall()
OperationalError: user-defined function raised exception
Testing reveals that "item" is passed as None: if item is None: return False
r = re.compile(expr, re.I)
return r.search(item) is not None
('John Butcher',)).fetchall()
[]
How can I get around this? I really want to be able to search by
regexp, and not just the standard SQL %-pattern.

--
Ben Wolfson
"However, identifying what we call 'time' or even 'space', which I
shall mention soon, is a very difficult problem, and a philosopher
would say that it is an extremely annoying subject."
(Soseki Natsume, "The Philosophical Foundations of Literature")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top