0

I'd like to use a very recent version of the sqlite3 shared library, directly compiled from the sources from https://www.sqlite.org.

Overwriting /usr/lib/x86_64-linux-gnu/libsqlite3.so or libsqlite3.so.0.8.6 with the new compiled library seems like a bad idea because it could break some of the OS tools - that use Python and the standard sqlite3 module and don't like a new version of this shared library.

Question: how can I duplicate the stdlib Python module sqlite3 into a module named sqlite3custom that, instead of using /usr/lib/python3.5/lib-dynload/_sqlite3.cpython-35m-x86_64-linux-gnu.so would use /path/to/my/custom/sqlite.so?

Then I would use import sqlite3custom in my code with exactly the same API than sqlite3, and this would avoid to touch to the built-in sqlite3 module.

Benefit: we could even have both in the same code, to do comparisons:

import sqlite3
print(sqlite3.sqlite_version)        # 3.23.1
import sqlite3custom
print(sqlite3custom.sqlite_version)  # 3.36 (2021-06-18), compiled from source 

Note: this is linked but slightly different to Upgrade Python's sqlite3 on Debian and Multiple versions of Sqlite3 for Python on the same server.

Basj
  • 41,386
  • 99
  • 383
  • 673

1 Answers1

0

I don't think you can use both versions of the sqlite3 library at the same time. But, to use the non-system library in your python code, you can just update LD_LIBRARY_PATH (put the folder that contains your version before the folder with the system version) Depending on how exactly you interact with sqlite3, maybe you would need to update PATH similarly.

Nielk
  • 760
  • 1
  • 6
  • 22