https://wiki.postgresql.org/wiki/Psycopg2_Tutorial

Поиск
Список
Период
Сортировка
От Rick Widmer
Тема https://wiki.postgresql.org/wiki/Psycopg2_Tutorial
Дата
Msg-id e10fad27-acfe-7319-90ef-ad92da3a1ea2@rickwidmer.com
обсуждение исходный текст
Список pgsql-www
May I suggest a subtle change to error handling examples on this page...


For example...

except:    print "I am unable to connect to the database"

Should be:

except psycopg2.Error as e:    print "I am unable to connect to the database: %s" % e



Postgress/psycopg2 return very good information in the exception that 
deserves to be displayed.  The print needs to display a %s formatted 
value of the exception because the exception contains structured data 
that does not display well.


except Exception as e:


would work as well, but the exception above should only trigger on 
database errors.

IMHO the error messages are worth knowing about, and should be part of 
the example.

Thanks, Rick








В списке pgsql-www по дате отправления:

Предыдущее
От: "Rader, David"
Дата:
Сообщение: Re: patch - BigSQL packages on Download
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: patch - BigSQL packages on Download