I want to empty a large SQLite table and then compact the database.
DB.exec(“VACUUM INTO ‘file:local?vfs=kvvfs’”)
The following error occurs:
Uncaught SQLite3Error: SQLITE_ERROR: sqlite3 result code 1: output file already exists.
Can I compact without a local file?
Alternatively: How can I delete the local file?
ghenne
2
You need to do DB.clearStorage() before DB.exec(“VACUUM INTO ‘file:local?vfs=kvvfs’”):
DB.clearStorage()
DB.exec("VACUUM INTO 'file:local?vfs=kvvfs'")
See Support for SQLite - NSB App Studio
If you need a temporary database, you can create one like this:
DBtemp = SqlOpenDatabase("sessionStorage")
It will get wipe out when you refresh the page. There is more information here:
https://sqlite.org/wasm/doc/trunk/persistence.md#kvvfs