More info on this. If I set timeout="1" and deliberately time.sleep(3) between connect and cursor.execute() I get back this error:
ProgrammingError: sapdb.SQLError: [700] (at 0) Session inactivity timeout (work rolled back) Which makes sense. But now I can't use the connection. However, if I call connect.rollback() then the connection IS usable once more. I would have thought that if sapdb rolled back for me I wouldn't also need to rollback. Is this correct behavior from the API? Jeff -----Original Message----- From: Dittmar, Daniel [mailto:[EMAIL PROTECTED] Sent: Friday, February 28, 2003 12:22 PM To: 'Jeff Robbins'; [EMAIL PROTECTED] Subject: RE: python connection object in a long-lived process >>> 1) once you instance a connection object, is it usable for the lifetime of your python process or are there circumstances where you must instance a new one to reconnect to the database? <<< When a session gets disconnected (timeout, database down), the driver tries to reconnect. If this fails, the connection object is no longer usable. I could check what happens if the driver tries a reconnect on every method call in this state. >>> 2) if the connection object is usable for the lifetime of your python process, are there (or could there be) ways to monitor and control its state? E.g. force it to try to reconnect right away, configure its retry timer, inquire or ping as to its state, etc... <<< A ping method might be useful. You can achieve the same effect by sending an arbitrary string to the database and catching syntax errors only. But there does exists a special command in the network protocol, and it should be used for this. Note that even when the driver is able to reconnect, it will still throw an exception. This is reasanable when a transaction has been broken. It is less so when the last command was a commit or rollback. This is a flaw in the implementation and I hope I can fix it sometime. >>> 3) if the connection object is not usable for the lifetime of your python process, what error codes indicate this definitively? <<< I would have thought that any such error would raise a Communication error (sapdb.sql) or OperationalError (sapdb.dbapi). But it seems that when the kernel is in admin mode, the driver gets a regular SQL error and passes this back to the client. SQLM.en: ENG -8000 SERVERDB must be restarted SQLM.en: ENG -4008 Unknown user name/password combination I admit the latter is unlikely. But then I thought it unlikely tham someone restarts the database and expects connection objects to persist. Daniel Dittmar -- Daniel Dittmar SAP DB, SAP Labs Berlin [EMAIL PROTECTED] http://www.sapdb.org/ _______________________________________________ sapdb.general mailing list [EMAIL PROTECTED] http://listserv.sap.com/mailman/listinfo/sapdb.general
