Re: pysqlite design decisions

Gerhard Häring <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Roger Binns wrote:
> [...] I am also baffled at the behaviour of pysqlite swallowing exceptions in
> callbacks (eg user defined functions).
> 
> === pysqlite ===
> 
> from pysqlite2 import dbapi2 as sqlite
> def badfunc(t):
> ~    return 1/0
> 
> con = sqlite.connect(":memory:")
> con.create_function("badfunc", 1, badfunc)
> cur = con.cursor()
> cur.execute("select badfunc(3)")
> 
> $ python func.py
> Traceback (most recent call last):
> ~  File "func.py", line 8, in ?
> ~    cur.execute("select badfunc(3)")
> pysqlite2.dbapi2.OperationalError: user-defined function raised exception

By adding this:

sqlite.enable_callback_tracebacks(1)

You get more tracebacks printed to stderr when errors happen in callback
functions (functions, aggregates, authorizers, etc.).

There once was a good reason for doing it this way, but I forgot what
exactly it was ;-) It had something to do with another error masking the
original one in some cases, IIRC.

> The next release of APSW (corresponding to SQLite 3.3.8) has these updates:
> 
> - Dummy frames from C code in exception tracebacks
> - String values with embedded nulls work (eg "foo\0bar") rather than
> truncating at the \0
> - You can load SQLite shared library extensions
> - Support for SQLites virtual tables
> http://www.sqlite.org/cvstrac/wiki?p=VirtualTables
> 
> The virtual tables are an IMHO very interesting.

They would sure be fun to use from Python, I'd really like to play with
them. I even started implementing them in pysqlite, but it's a lot to wrap
and will take a quite some time.

If we could integrate APSW and pysqlite in such a way that I could
implement virtual tables on pysqlite connections, that would be really
great. Basically what we'd need is some way that APSW could make sense of a
pysqlite connection object and use its sqlite3* handle. Do you think that's
feasible?

- -- Gerhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFdfTEdIO4ozGCH14RAr7KAKCMm3plFvMnu9ZKBWEAj772+FLaJgCcDfWi
/pELEcNVtPqwRHYs2pOcWsw=
=tf/n
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.