Thank you, but I need to distinguish the errors in the except statement, something like that:

     connection = connectionForURI('postgres://'+user+':'+password+'@'+host+'/'+database?debug=True)
     sqlhub.processConnection = connection
     connection.query("SELECT 1")
except OperationalError, e:
     if (user or password are incorrect):
         show a message
     elif (the server is not working):
         to do another thing

How can I ask the OperationalError object 'e' to do that?

2013/9/12 Daniel Monteiro Basso <>
Add ?debug=True to the connection URL. Also, instead of adding strings, consider formatting one, such as:
connection = connectionForURI('postgres://{user}:{password}@{host}/{database}?debug=True'.format(locals()))



On Thu, Sep 12, 2013 at 6:07 PM, Francisco Chiotta <> wrote:
        I have a question related with the connections. I am using the following code for that:

     connection = connectionForURI('postgres://'+user+':'+password+'@'+host+'/'+database)
     sqlhub.processConnection = connection
     connection.query("SELECT 1")
except OperationalError:
     print "error"

but, I don't know if the error is because the user and password are wrong or the sever is not working. How can I verify that? for example, maybe, with a error code but I don't know how to get it.


How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
sqlobject-discuss mailing list