I have a Python binary which uses SQLite as its backend database. SQLite's documentation and the code suggests that setting any of the following 3 environment variables should work:
export TMP=/var/tmp/sqlite/
export TEMP=/var/tmp/sqlite/
export TEMPDIR=/var/tmp/sqlite/
If I export the above variables in my bash script just before I start my Python binary, it does not help.
Another option I tried is calling putenv()
by setting os.environ
:
os.environ['TMP'] = /var/tmp/sqlite/
os.environ['TEMP'] = /var/tmp/sqlite/
os.environ['TEMPDIR'] = /var/tmp/sqlite/
None of above options has helped in persuading SQLite to use /var/tmp/sqlite
as its temp store directory. The only option that has worked - which SQLite's documentation says is deprecated - is setting the temp_store_directory
pragma statement:
PRAGMA temp_store_directory = '/egnyte/.work/sqlite_temp'
Since using the pragma statement is not the choice I would like to make, is there any other trick?
For version 3.8.1+ (released October 2013), it's cleaner to use the new
SQLITE_TMPDIR
environment variable instead ofTMPDIR
, since the latter is used by Unix software other than SQLite.From the release notes:
The environment variables you are referring to are indeed what sqlite looks for but in Windows, not UNIX.
In Unix, the environment variable you need to set is
TMPDIR
as shown in the sources: