Re: Connection errors

Oleg Broytman <[email protected]> Thu, 12 Sep 2013 21:15:39 +0400
Newsgroups gmane.comp.python.sqlobject
Message-ID <[email protected]>
Hi!

On Thu, Sep 12, 2013 at 02:07:48PM -0300, Francisco Chiotta <[email protected]> wrote:
> Hello,
>         I have a question related with the connections. I am using the
> following code for that:
> 
> try:
>      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.

   Hope this helps:

except OperationalError, e:
     print "error:", e

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            [email protected]
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
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
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk