开发者

Is it safe to close SQLite db more than once?

I'm using SQLite with python.

My code for closing SQL开发者_如何学Cite 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?


Yes it's save. Just make sure, that you don't want to operate on a closed connection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜