How to use APSW with other SQLite-using C extensions #424
-
Hi, If I am using APSW together with another C extension that uses SQLite (say, an extension that defines a custom VFS), do I need to take any special care at build time? For example, do I need to make sure that both are linked dynamically against the same SQLite library? Or is there some way to make things work even if APSW has SQLite compiled in statically? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You don't need to do anything special and it should all work. The only gotcha is that extension loading is off by default, and you need to enable it - eg with enableloadextension. It is also the case that the default compilation of SQLite has loadable extension functionality compiled out, but virtually everyone has the functionality compiled in. Loadable extensions are not linked against SQLite. Instead the initialisation method of the extension is passed a list of function pointers. That guarantees the correct functions are used no matter how and when the extension was compiled, and even if SQLite is compiled in statically. You can see that here. |
Beta Was this translation helpful? Give feedback.
-
You can call Connection.loadextension or SQL load_extension() function. The standard SQLite doc applies. This is the test extension used when verifying the functionality with APSW. This is the code used to build the test extension which ensures it uses the same compiler and settings as what was used to build Python. |
Beta Was this translation helpful? Give feedback.
You don't need to do anything special and it should all work. The only gotcha is that extension loading is off by default, and you need to enable it - eg with enableloadextension. It is also the case that the default compilation of SQLite has loadable extension functionality compiled out, but virtually everyone has the functionality compiled in.
Loadable extensions are not linked against SQLite. Instead the initialisation method of the extension is passed a list of function pointers. That guarantees the correct functions are used no matter how and when the extension was compiled, and even if SQLite is compiled in statically. You can see that here.