melonfacedoom
melonfacedoom

Reputation: 85

Cannot delete sqlite3 database file after closing connection

I am trying to delete a sqlite3 database file. After I close the connection and try to delete the file, I receive and error stating that the file is being used by another process. I've been searching for an answer for a little while, but I feel like a lot of the solutions seem way more convoluted than should be necessary. This solution seems like exactly what I'm looking for, but I'm not sure what it means by "Once you have your Context". Here is my code:

import sqlite3
import os.path

db = "data.db"
con = sqlite3.connect(db)
c = con.cursor()

c.execute('''CREATE TABLE my_table (a TEXT, b TEXT, c TEXT)''')
c.execute('''INSERT INTO my_table VALUES(?,?,?)''',("test1","test2","test3"))

con.close
os.remove(db)

Upvotes: 1

Views: 2498

Answers (1)

Dmitriusan
Dmitriusan

Reputation: 12399

You are not really calling con.close (missing parentheses)

Upvotes: 3

Related Questions