Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51732
| References | <13d04b58a1024039b66ea54a9d5bb85b@exch.activenetwerx.com> <assp.0921cf9ff5.8bca791c6c264850ac99e0c98361fb4e@exch.activenetwerx.com> <kt3qht$grc$1@ger.gmane.org> |
|---|---|
| Date | 2013-08-01 15:02 +0100 |
| Subject | RE: sqlite3 version lacks instr |
| From | Fábio Santos <fabiosantosart@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.77.1375365727.1251.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
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 "<stdin>", line 1, in <module>
> 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
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: sqlite3 version lacks instr Fábio Santos <fabiosantosart@gmail.com> - 2013-08-01 15:02 +0100
csiph-web