[DB-SIG] ping method for connection objects

M.-A. Lemburg mal@lemburg.com
Tue, 08 Oct 2002 22:45:33 +0200


Michael C. Neel wrote:
> Just a request for the spec, is that a ping method be added to the
> connection object to test if the db handle is still valid, not unlike
> perl's DBI interface.  Ideally a reconnect method would be handy as
> well.

I'm not sure whether such a feature is available on a broad
enough basis, e.g. ODBC only recently added such a feature
to the spec and it's not available in all drivers.

Maybe we just need a portable way to test the connection,
e.g. a dummy SQL statement ?

try:
      connection.cursor().execute('select x from nonexistingtable')
except OperationalError:
      # reconnect
      pass
except ProgrammingError:
      # alive
      pass

> Otherwise, I find the spec very complete!

Same here :-)

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/