SQLITE_TMPDIR or pragma temp_store_directory
For my application, where I use SQLite in an Electron app for macOS with sandbox mode, I need to change the location where SQLite stores its temporary files. According to SQLite documentation, I can set the destination path using either a pragma or an environment variable. However, no matter what I try, better-sqlite3 stores the files in the same directory where I create the SQL file. Is there an option I might have missed to set the temporary file location?
Well, the pragma is deprecated
About which temporary files are we talking here? Afaik SQLite does not support using a temp directory for all of them, but only the one which are used for temporary tables etc.
If journaling is set to WAL it creates two journaling files in the same directory as the database file. I need these files to be moved to a directory where I have write access. When creating a new file, or opening an existing file, the MacOS App sandbox does only give me access to write this one file, however if I can set a SQLlite to write journals in an writable directory it could work. My current fix is to set journaling to memory, but this is not a good solution....
If this is not possible then I must make a more complex fix, e.g. create the file in the writable temporary directory and move it after usage to its destination.
On Tue, Jan 14, 2025 at 9:57 PM neoxpert @.***> wrote:
Well, the pragma is deprecated https://www.sqlite.org/pragma.html#pragma_temp_store_directory
About which temporary files are we talking here? Afaik SQLite does not support using a temp directory for all of them, but only the one which are used for temporary tables etc.
— Reply to this email directly, view it on GitHub https://github.com/WiseLibs/better-sqlite3/issues/1314#issuecomment-2591087654, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUXMIRNGJ2ON6SYXFRLR3F32KV225AVCNFSM6AAAAABVEXTC4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJRGA4DONRVGQ . You are receiving this because you authored the thread.Message ID: @.***>
The WAL file will always be stored next to the database file, when not using memory persistence. There is no way to change this behaviour - except you want to deal with changing the C source code of SQLite.
Ok, thanks for the clarification.
On Wed, Jan 15, 2025 at 2:49 PM neoxpert @.***> wrote:
The WAL file will always be stored next to the database file, when not using memory persistence. There is no way to change this behaviour - except you want to deal with changing the C source code of SQLite.
— Reply to this email directly, view it on GitHub https://github.com/WiseLibs/better-sqlite3/issues/1314#issuecomment-2592906007, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUXMIRITQ4GZOHJY7QSLGFD2KZRMZAVCNFSM6AAAAABVEXTC4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJSHEYDMMBQG4 . You are receiving this because you authored the thread.Message ID: @.***>