Forums

Sqlite3 support for CTE and WITH clause

I've just deployed my project on pythonanywhere.com. I'm using Django 1.10.4 with sqlite3 as database. I've used some raw queries inside my application which make use of CTE and WITH clause. Sqlite3 supports them from version 3.8.3 (see https://www.sqlite.org/changes.html), unfortunately on pythonanywhere the available version of sqlite3 is 3.8.2. Do any of you know how to solve the problem?

Maybe you could somehow download and compile and install a copy of sqlite and its libraries in your home folder, and then somehow install a python sqlite library that would replace the standard library one? It sounds a little tricky, but I see someone doing something similar on OSX here: http://stackoverflow.com/questions/26345972/how-do-i-upgrade-the-sqlite-version-used-by-pythons-sqlite3-module-on-mac so might be worth trying?

I've managed to compile sqlite3 v 3.16.2 and generate a shared library object. If I set inside bash shell the variable LD_LIBRARY_PATH to the location where the shared library is I am able to run "python manage.py shell" and import the new version of the library, but it doesn't work for my server instance since the LD_LIBRARY_PATH variable does not appear to be set. At first I put

export LD_LIBRARY_PATH=/home/Sirion/opt/lib

inside my .bashrc, which (obviously) doesn't get called when the server is run. So I moved the export inside postactivate hook of my virtualenv, but still LD_LIBRARY_PATH doesn't appear at all among system variables when I print the content of os.environ inside wsgi.py (before creating the wsgi application).

So, do you make any kind of trick when initializing the server which obfuscates LD_LIBRARY_PATH variable?

you can put it in the wsgi.py file. See this

Already tried, but doesn't work, see the answer here. Also, I've tried Glenn Maynard and Will Pierce's solutions here, but the former doesn't work (did not expect though, since sys.path is used for modules import, not dynamic libraries, I think), the latter gives a 502-backend error when I reload the web app.

Other suggestions?