Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'shipped': 0.05; 'function:': 0.09; 'subject:version': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '>>': 0.16; 'b):': 0.16; 'guys,': 0.16; 'sqlite': 0.16; 'subject:sqlite3': 0.16; 'to:addr:web.de': 0.16; 'wrote:': 0.18; 'seems': 0.21; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'this?': 0.23; '>>>': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'forgot': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; '"",': 0.31; 'anyone': 0.31; 'file': 0.32; 'url:python': 0.33; '(most': 0.33; 'skip:& 30': 0.33; 'skip:d 20': 0.34; 'could': 0.34; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'version': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'too': 0.37; 'skip:o 20': 0.38; 'skip:& 10': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'sure': 0.39; 'url:mail': 0.40; 'such': 0.63; 'skip:n 10': 0.64; 'within': 0.65; 'jul': 0.74; 'faster.': 0.84; 'late,': 0.84; 'utilized': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=xp8nqLC6QEKEKz6OwI8P4B+lcsNruA3ogwuB3BKeWdA=; b=MXnr2zXRJcy7TZloN7jP4dUiS9BwM3dnuUIl7D0UYLt0g9I8Xl36sFPV+2OKNH4Aau ylTli/oQTzqmWsK93ZIKrlIZ8waOmOBrx8Yq5MghF3RyQWRoSMaOjg0CUsTDjHO08HYi OACL4oCzcDAMxXyLR4lpUZHyjch/wQGl2gLrCvSl/q2jT6kjIxmoB9I/aJj5wHLagrKe Jtxr3yK7qLjjQWlIdFwgPVoBH5C4EBufBF+GZ2lnoErlenq53cYBmskv5gdE9IY1eCmf FgNIrukQKls8X6a7befsceweC9qody7tjqVGce7dx974HPKMDVwwvGAwophFcKfBXvZA J9GQ== MIME-Version: 1.0 X-Received: by 10.224.161.76 with SMTP id q12mr5053137qax.3.1375365724563; Thu, 01 Aug 2013 07:02:04 -0700 (PDT) In-Reply-To: References: <13d04b58a1024039b66ea54a9d5bb85b@exch.activenetwerx.com> Date: Thu, 1 Aug 2013 15:02:04 +0100 Subject: RE: sqlite3 version lacks instr From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: Peter Otten <__peter__@web.de> Content-Type: multipart/alternative; boundary=089e0149528e73195504e2e34938 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 85 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375365727 news.xs4all.nl 15964 [2001:888:2000:d::a6]:44350 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51732 --089e0149528e73195504e2e34938 Content-Type: text/plain; charset=ISO-8859-1 I'm not sure but it seems like you could use operator.__contains__ . it might be faster. On 28 Jul 2013 20:18, "Peter Otten" <__peter__@web.de> wrote: > Joseph L. Casale wrote: > > >> Has anyone encountered this and utilized other existing functions > >> within the shipped 3.6.21 sqlite version to accomplish this? > > > > Sorry guys, forgot about create_function... > > Too late, I already did the demo ;) > > >>> import sqlite3 > >>> db = sqlite3.connect(":memory:") > >>> cs = db.cursor() > >>> cs.execute('select instr("the quick brown fox", > "brown")').fetchone()[0] > Traceback (most recent call last): > File "", line 1, in > sqlite3.OperationalError: no such function: instr > >>> def instr(a, b): > ... return a.find(b) + 1 # add NULL-handling etc. > ... > >>> db.create_function("instr", 2, instr) > >>> cs.execute('select instr("the quick brown fox", > "brown")').fetchone()[0] > 11 > >>> cs.execute('select instr("the quick brown fox", "red")').fetchone()[0] > 0 > > > -- > http://mail.python.org/mailman/listinfo/python-list > --089e0149528e73195504e2e34938 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

I'm not sure but it seems like you could use operator.__= contains__ . it might be faster.

On 28 Jul 2013 20:18, "Peter Otten" &l= t;__peter__@web.de> wrote:
Joseph L. Casale wrote:

>> Has anyone encountered this and utilized other existing functions<= br> >> within the shipped 3.6.21 sqlite version to accomplish this?
>
> Sorry guys, forgot about create_function...

Too late, I already did the demo ;)

>>> import sqlite3
>>> db =3D sqlite3.connect(":memory:")
>>> cs =3D db.cursor()
>>> cs.execute('select instr("the quick brown fox", = "brown")').fetchone()[0]
Traceback (most recent call last):
=A0 File "<stdin>", line 1, in <module>
sqlite3.OperationalError: no such function: instr
>>> def instr(a, b):
... =A0 =A0 return a.find(b) + 1 # add NULL-handling etc.
...
>>> db.create_function("instr", 2, instr)
>>> cs.execute('select instr("the quick brown fox", = "brown")').fetchone()[0]
11
>>> cs.execute('select instr("the quick brown fox", = "red")').fetchone()[0]
0


--
http://mail.python.org/mailman/listinfo/python-list
--089e0149528e73195504e2e34938--