Getting the SQLSTATE after a failed connection
| От | Daniele Varrazzo |
|---|---|
| Тема | Getting the SQLSTATE after a failed connection |
| Дата | |
| Msg-id | CA+mi_8ZRi-NJsOw5SFUMXACLm-OFoS+DeRV3_5m7RgHfPXx1gg@mail.gmail.com обсуждение исходный текст |
| Ответы |
Re: Getting the SQLSTATE after a failed connection
Re: Getting the SQLSTATE after a failed connection |
| Список | pgsql-hackers |
Hello, in ticket <https://github.com/psycopg/psycopg/issues/1188> an user showed that, upon a failed connection attempt because of a bad password, the server sends a SQLSTATE 28P01 message. However psycopg cannot raise the expected `InvalidPassword` exception, because the only way to get the SQLSTATE seems to be from a PGresult via PQresultErrorField and I fail to see any API call to get the info from a PGconn. Using `PQmakeEmptyPGresult` didn't help either: PQresultErrorField reports no data about the error. Browsing the code, it seems that PqMsg_CommandComplete is only handled in isBusy/getResult. There is a promising `last_sqlstate` in the structure but it seems only used internally and not exposed. Is there any way to get the last SQLSTATE from the connection object or is that information lost? Thank you very much -- Daniele
В списке pgsql-hackers по дате отправления: