tl;dr:
How do i close a read-/ write connection to a database in Sqlite.swift?
Background story:
I am using the sqlite.swift
framework to manage a .sqlite file (data.sqlite) that is copied from the application bundle (bootstrap.sqlite) on app start (if it doesn't exist yet).
This sqlite file from the bundle contains various bootstrap data.
I want the user to "reset all data" and my approach so far is to delete the data.sqlite file and copy the bootstrap.sqlite file again - on runtime
Unfortunately there might still be open connections / running requests that obviously fail / crash / screw up the file.
I tried
dbWriteConnection?.interrupt()
dbReadConnection?.interrupt()
try? fileManager.removeItem(at: localSqlitePathURL)
But this seems to somehow delete the table within the sqlite.
Is there any way to cancel all running requests / guarantee that the connections are idle?