Reputation: 190859
I'm using SQLite with python.
My code for closing SQLite DB is as follows.
def close(self):
if not self.closed:
self.db.closeDB()
self.closed = True
def closeDB(self):
self.cursor.close()
I have one variable 'closed' not to close the db twice. Is this variable necessary? What would happen if I call the close() function twice?
Upvotes: 1
Views: 268
Reputation: 188064
Yes it's save. Just make sure, that you don't want to operate on a closed connection.
Upvotes: 2