Closed jdevdevdev closed 6 months ago
Hey there. Just for my understanding, are you saying that you get that error when accessing the database after calling overwriteDatabaseFile
? You shouldn't get it while overwriting the database.
Also, are you sure that the database you tried to import was properly closed first? If the database had an open WAL file with uncommitted transactions that got left behind when you tried to import it, I can see why that error would happen. Though, it's odd that it worked when using importDb
if that was the case and you used the same database both times.
I wasn't aware of the importDb
method. Looks like they added that fairly recently. I'd definitely be open to adopting that. It looks like a better solution than what overwriteDatabaseFile
currently does. It sounds like you already wrote up a proof of concept using it. If so, could you post that here or open a pull request with it?
Apologies for my vague description.
Yes that is correct the error occurred after using overwriteDatabaseFile
then accessing the the db once the function has completed.
I believe that I closed it correctly. There are no -wal files at point of upload and I manually switch the db back and forth between modes to check with:
PRAGMA journal_mode=WAL;
PRAGMA journal_mode=DELETE;
I have a reproduction here with the fix and a pr here https://github.com/DallasHoff/sqlocal/pull/12
Let me know if this helps.
Just to piggyback on this thread, I just discovered that overwriteDatabaseFile
fails in Safari, because Safari does not support the FileSystemFileHandle.createWritable()
method. (See the "Browser compatibility" table on that page.)
It appears to me that the overwriteDatabaseFile
method is the only place that this project tries to use FileSystemFileHandle.createWritable()
, so if you can replace that method with something else that works with Safari, that would be great!
I'm happy to make this a separate GitHub issue, if that would be more helpful.
This pr https://github.com/DallasHoff/sqlocal/pull/12 might fix it.
It adds a new function importDatabaseFile
.
It's effect should be the same as the overwriteDatabaseFile
while not using the createWriteable()
function.
Unfortunately I do not have a machine with safari to confirm.
Released the changes to overwriteDatabaseFile
in version 0.7.0
Thanks for writing this library! it looks very clean.
When using overwriteDatabaseFile with a db that has WAL enabled I get the following error:
Error: SQLITE_CANTOPEN: sqlite3 result code 14: unable to open database file
Passing the byte array to the worker and using the
sqlite3.oo1.OpfsDb.importDb('filename', byteArray);
function does allow it to be accessed.Is this something that is open to being supported in the future?