|
From: Oleg B. <ph...@ph...> - 2013-09-12 18:56:21
|
On Thu, Sep 12, 2013 at 03:33:36PM -0300, Francisco Chiotta <fra...@gm...> wrote:
> Thank you, but I need to distinguish the errors in the except statement,
> something like that:
>
> try:
> 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?
I don't think database drivers provide such information. You can try
to parse the error message, but they are very database- and
locale-dependent.
Oleg.
--
Oleg Broytman http://phdru.name/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|