tanrj / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

No way to determine if a connection has been dropped #66

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open a connection to a DB that drops connections after a timeout
2. Wait.
3. Try to use the connection. There is nothing in the interface that 
allows you to determine if the connection is still open.

What is the expected output? What do you see instead?
I expect a value on the connection object 'closed' once the connection has 
been dropped.

What version of the product are you using? On what operating system?
Current -- 2.1.X

Original issue reported on code.google.com by gbron...@gmail.com on 13 Aug 2009 at 2:58

GoogleCodeExporter commented 8 years ago
Unfortunately this is by design since ODBC is client/server.  Databases don't
typically notify the clients, so there is no way for pyodbc to know.

What database are you using?  If there is way to find out, it seems reasonable 
to add
a flag or method that checks.

You didn't mention your operating system.  If you are using ODBC on Windows, 
using
connection pooling usually fixes this since a lot of drivers will check under 
the covers.

If not, you'll need your manual connection pool to perform a quick test before
handing out the connection.  I know SQL Server has a very fast stored procedure 
the
driver uses under the covers (xp_reset I think).  I've done this with manual
connection pools on Linux.  (Also, if you are using PostgreSQL for a large
website/server, consider using pgbounce.  I've heard a lot of good things about 
it.)

Original comment by mkleehammer on 14 Aug 2009 at 2:06

GoogleCodeExporter commented 8 years ago
To clarify: 

1) This is using a python client connecting to Netezza via the linux ODBC 
library;
client is running on linux.

So this is a bit bleeding edge.

Original comment by gbron...@gmail.com on 11 Nov 2009 at 9:57

GoogleCodeExporter commented 8 years ago
I'm going to have to close this since it isn't actually a pyodbc issue.

I hate to do so without finding something helpful for you, but I haven't been 
able to.  Netezza isn't real 
forthcoming with their documentation.

I do recommend bringing it up in the discussion group, though.

Original comment by mkleehammer on 31 Dec 2009 at 6:59

GoogleCodeExporter commented 8 years ago

Original comment by mkleehammer on 21 Nov 2010 at 4:43