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

J

John Salerno

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.
 
J

John Salerno

John said:
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.
 
N

Nick Vatamaniuc

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top