Python sqlite3: run different sqlite3 version
Question: I'm running a Django project using sqlite as one of the databases. I would
like to run the most recent SQLite version when running the project. By that I
mean the most recent sqlite binary, not the sqlite python library.

I have a local sqlite3 binary that is not the system default and I can't
change the default sqlite3 version.

I'm not using Django's ORM but have replaced it with a standalone SQLAlchemy
version.

I've found one related link but that had to do with running the most recent
python sqlite library version.

[How to upgrade sqlite3 in python 2.7.3 inside a
virtualenv?](http://stackoverflow.com/questions/14541869/how-to-upgrade-
sqlite3-in-python-2-7-3-inside-a-virtualenv)


Answer: Python can't use the `sqlite3` binary directly. It always uses a module which
is linked against the `sqlite3` shared library. That means you have to follow
the instructions in "[How to upgrade sqlite3 in python 2.7.3 inside a
virtualenv?](http://stackoverflow.com/questions/14541869/how-to-upgrade-
sqlite3-in-python-2-7-3-inside-a-virtualenv)" to create a version of the
`pysqlite` module in your virtualenv.

You can then use this import

    
    
    from pysqlite2 import dbapi2 as sqlite
    

to shadow the system's default `sqlite` module with the new one.

Another option would be to get Python's source code, compile everything and
copy the file `sqlite.so` into your virtualenv. The drawback of this approach
is that it's brittle and hard to repeat by other people.

