I am testing some database manipulation with sqlite3 in python, but for some reason I am not able to replicate some commands from SQL in sqlite3. In my case I have a function that tests a query and it creates a sample database with some tables and data. However, I am not able to drop the database using sqlite and rather have to use the following code:
import os
os.remove(databaseName)
Would sqlite3 have any command for dropping a database, or even creating a temporary one?
There is no command in sqlite to drop a database, as the database is saved in a file. To drop it you would just delete the file.
You can however create in-memory databases by using :memory: as the filename: conn = sqlite3.connect(':memory:'). See https://www.sqlite.org/inmemorydb.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With