SQLite Forum

Setting temp_store_directory on Windows in future proof way
Login
SQLite3 uses the Windows API that retrieves the path of the temp directory from the Operating System.

<https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha>

In short, the temp directory is specified in the process environment and looks for the value of the TMP variable, then the TEMP variable, then the USERPROFILE variable, then the Windows System directory; the first one found wins.