Thomas Nyberg
unread,Feb 13, 2017, 5:06:47 PM2/13/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com, Thomas Nyberg
Hello,
I have a question about regexes and sqlite3. I am executing a certain
line of code:
>>> regex = 'NET | INCOME'
>>> Table.objects.filter(name__iregex=regex).
When I have it print out the SQL sent, I get the following (this is a
simplified, but equivalent version):
SELECT *
FROM "table"
WHERE "table"."name"
REGEXP '(?i)' || 'NET | INCOME'
LIMIT 21
However if I execute that directly against the sqlite database i get the
following error:
sqlite3.OperationalError: no such function: REGEXP
I thought that maybe this magic was handled in python's sqlite3 module,
but if i do it there i get the same error. So basically my question is,
can anyone tell me where this is transformed into regular sql? it
obviously happens somehwere (I get no error when running in django after
all), but I can't for the life of me figure out where.
Thanks a lot!
Thomas
PS: I have tried using the shell_plus --print-sql extension, but that
shows me the same thing.
PPS: Obviously not django-related, but if anyone knows how to get a
sqlite database to log all queries issued against it, that would also
obviously solve this issue.