Use PyCapsule_* for the _sqlite3 c extension

I have an idea for a C extension module of mine, however it would require access to the api’s in the _sqlite3 c extension itself. I notice how easy it is to access the api in the “datetime” module via c api which uses capsules and would love to be able to do the same thing for the default shipped _sqlite3 c extension module itself. I could use PyImport_ImportModule("sqlite3"); But because of the fact that I am writing C extension code an easier way is to do something similar to the datetime module and use it’s pure C api instead. Also because then there could be a header file named _sqlite3.h that could get provided in the include directory in normal python distributions when installed normally.

Have you thought of using a combination of C and python code to give you access to the sqlite3 module?

If you need a number of SQL database actions then you could call into your python code to do the sqlite work on behalf of your C code.

1 Like