Re: Python sqlite and regex.

2006-05-19 Thread Ben Finney
John Salerno <[EMAIL PROTECTED]> writes: > Paul McGuire wrote: > > "Paul McGuire" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >> where '*' matches one or more characters, and '?' matches any > >> single > > > > oops, I meant '*' matches zero or more characters. > > '?'

Re: Python sqlite and regex.

2006-05-19 Thread Dan Sommers
On Fri, 19 May 2006 18:52:38 GMT, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > "Dan Sommers" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Doesn't SQL already have lightweight wildcards? >> >> SELECT somefield FROM sometable WHERE someotherfield LIKE '%foo%' > Yes it does - '%

Re: Python sqlite and regex.

2006-05-19 Thread Matt Good
Oops, sorry about the confusion regarding the built-in REGEXP. That's kind of disappointing. It would appear that the user-defined regexp function in the original post should work assuming the SQL and regex syntax errors are corrected. However, there *is* a GLOB built-in to SQLite 3 that has a d

Re: Python sqlite and regex.

2006-05-19 Thread Paul McGuire
"Dan Sommers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Fri, 19 May 2006 17:44:45 GMT, > "Paul McGuire" <[EMAIL PROTECTED]> wrote: > > > "Gerhard Häring" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > >> """ > >> The REGEXP operator is a special syntax f

Re: Python sqlite and regex.

2006-05-19 Thread Dan Sommers
On Fri, 19 May 2006 17:44:45 GMT, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > "Gerhard Häring" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> """ >> The REGEXP operator is a special syntax for the regexp() user >> function. No regexp() user function is defined by default and so

Re: Python sqlite and regex.

2006-05-19 Thread Paul McGuire
"John Salerno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Paul McGuire wrote: > > "Paul McGuire" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >> where '*' matches one or more characters, and '?' matches any single > > > > oops, I meant '*' matches zero or

Re: Python sqlite and regex.

2006-05-19 Thread John Salerno
Paul McGuire wrote: > "Paul McGuire" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> where '*' matches one or more characters, and '?' matches any single > > oops, I meant '*' matches zero or more characters. '?' also matches 0 characters -- http://mail.python.org/mailman/lis

Re: Python sqlite and regex.

2006-05-19 Thread Paul McGuire
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > where '*' matches one or more characters, and '?' matches any single oops, I meant '*' matches zero or more characters. In many applications, these tests are sufficient for most user queries. And this eliminates the pr

Re: Python sqlite and regex.

2006-05-19 Thread Paul McGuire
"Gerhard Häring" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Matt Good wrote: > > SQLite3 already has a REGEXP function, so you don't need to create your > > own. [...] > > Yes, but SQLite does not include a regular expression en

Re: Python sqlite and regex.

2006-05-19 Thread Gerhard Häring
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Matt Good wrote: > SQLite3 already has a REGEXP function, so you don't need to create your > own. [...] Yes, but SQLite does not include a regular expression engine, and thus according to the SQLite docs you need to register a REGEXP function in order

Re: Python sqlite and regex.

2006-05-19 Thread Matt Good
SQLite3 already has a REGEXP function, so you don't need to create your own. As Dan mentioned you also have a problem in your expression: 'aa.[0-9]) You need a closing quote on the expression, and you need to match the close paren with an open paren, or remove it. Also, in case you weren't aware,

Re: Python sqlite and regex.

2006-05-19 Thread Dan Sommers
On Fri, 19 May 2006 14:47:10 +0200, Julien ARNOUX <[EMAIL PROTECTED]> wrote: > cur.execute("select foo from test where foo regex 'aa.[0-9])") > and the error is: > cur.execute('select foo from test where foo regex tata') > apsw.SQLError: SQLError: near "regex": syntax error I think you're missi

Python sqlite and regex.

2006-05-19 Thread Julien ARNOUX
Hi, I'd like to use regular expressions in sqlite query, I using apsw module but it doesn't work...Can you help me ? My script: import apsw import re path = 'db/db.db3' #regexp function (extract from python-list discusion) def regexp(expr, item): reg = re.compile(expr) return reg.match(i