How does one close a sqlite database opened by this module?

Sep 15, 2014 at 4:18 PM
so basically here is what i am doing:

i connect to a webshare and download a sqlite database file to my local harddrive, for testing purposes i used "c:\test.sqlite" in this example.

then i do this:

new-psdrive -name "test_db" -psprovider "SQLite" -root "Data Source=C:\test.sqlite"
$test = get-childitem -name "test_db:/test_table"
remove-psdrive -name test_db
remove-item C:\test.sqlite

all works fine, until remove-item throws an error, telling me the file is still in use. checking open file handles confirms that the file is indeed still in use by the powershell process. only possible way to close the handle is to close and re-open powershell, which renders my script pretty much useless.

since opening a database with new-psdrive works, i thought remove-psdrive would work just the same to close it. actually, it will remove the psdrive handle, so i can't access the database anymore, but how can i close the actual file?

please help, i really need this to work -.-
May 4, 2015 at 8:32 AM
Try using the following command after Remove-PSDrive and before Remove-Item: "Remove-Module SQLite"