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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Salerno

    #1

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

    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.
  • John Salerno

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

    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.clos e()
    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.

    Comment

    • Nick Vatamaniuc

      #3
      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.clos e()
      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.

      Comment

      Working...