Passing a sqlite connection into an extension module
mahall at ncsa.uiuc.edu
Mon Oct 19 22:49:04 CEST 2009
I'm trying to find out if there is a way to share a sqlite database
connection between python and an extension module written in C or C+
My setup is that I have some pretty intensive OpenGL rendering code
that gets its values from a largish sqlite database, performs a fair
bit of computation, and then draws. I'm throwing everything I can at
it to keep the code in python (numpy, Cython, vertex arrays and
drawlists), but the initial rendering is very slow, and it's fast
becoming much more time consuming for me to optimize the python than
it would be to write equivalent code in a C++ extension module.
However, I would like to have access to the same database from within
Python for running lesser queries, and for prototyping new features.
The problem is that I may be running from an in-memory database, and I
might also be using temporary tables (for a cache), which are not
shared across separate connections. I would like to grab the pointer
to the sqlite3 connection struct, and pass it to an extension module
so that I can use sqlite's native API. I can not find any way to do
such a thing in either the standard sqlite module, or in APSW.
Has anyone had any experience with this? I can think of some
workarounds (such as hack APSW, among other ideas). Any caveats?
More information about the Python-list