Re: checking if a sqlite connection and/or cursor is still open?



I am not familiar with SQLite driver, but a typical Pythonic way to
check if you can do something is to just try it, and see what happens.
In more practical terms: try to just use the cursor or the connection
and see if an exception will be raised.

Nick V.



John Salerno wrote:
John Salerno wrote:
Is there a way to check if a SQLite connection and cursor object are
still open? I took a look at the docs and the DB API but didn't see
anything like this.

Thanks.

Well, I might have somewhat solved this problem. Since SQLite allows you
to use execute* methods directly on the connection object (thus no need
to create a cursor object), all I need to do is call connection.close()
and this doesn't seem to raise an error even if the connection has
already been closed.

I'm still curious if there's a way to check for an open connection, but
it seems like without the cursor object, the task is much easier.

.



Relevant Pages