Search code examples
pythonsqliteubuntu

How can I see which sqlite3 binary the sqlite3 Python module uses on Ubuntu 16.04?


How can I see which sqlite3 binary (containing the SQLite relational database management system) does the sqlite3 Python module use on Ubuntu 16.04?

I unsuccessfully looked at /usr/lib/python3.7/sqlite3 and https://docs.python.org/3/library/sqlite3.html. I use Python 3.7.

The output of

python -c "import sqlite3; print(sqlite3.__file__)"

is /usr/lib/python3.7/sqlite3/__init__.py


Solution

  • It's not going to use the sqlite3 executable directly if that's what you're thinking. It's going to be linked to the sqlite3 dynamic library installed on your system. To find out which particularly library it's linked to, use ldd on the _sqlite3 python c extension. The _sqlite3 module is the underlying interface that the sqlite3 module relies on.

    $ ldd `find /usr/lib/python3.7/ -name '_sqlite3*'` | grep sqlite
        libsqlite3.so.0 => /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f47705a2000)