'Psycopg2.errors' not referenced in packaged

Поиск
Список
Период
Сортировка
От Patrick Starrenburg
Тема 'Psycopg2.errors' not referenced in packaged
Дата
Msg-id CA+6L-Z9b1p5Xu5P_24GjGv-X1yRdR-ufqehSLGYu2QUMJmXp8Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: 'Psycopg2.errors' not referenced in packaged  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Список psycopg
Hi

I am using psycopg2 in a Django app. In my code I am checking for various exceptions, one of which is foreign key violations.

I see in the psycopg2 docs https://www.psycopg.org/docs/errors.html that ForeignKeyViolation
is under the base IntegrityError exception. I would like to be able to specifically catch, and respond to the ForeignKeyViolation error. I am coding using the recommendation in the docs (below).

It is working (a forced FK violation is specifically caught) my question is though that in my IDE (PyCharm) it reports that it cannot find the reference 'errors' and I cannot use dotted links to drill down to the errors.ForeignKeyViolation function.

I can type psycopg2.IntegrityError and reference to it is found (and I see that it is listed in the __init.py__ file).

When I Google this some say it is a PyCharm bug, some say that PyCharm is following the Python package convention.

Can anyone advise.

Thanks in advance.

Patrick

try:
cursor_wsr.close()
conn.commit()
conn.close()
except psycopg2.errors.ForeignKeyViolation as err:

Cannot find reference 'errors' in '__init__.py | __init__.py'
Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.

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

Предыдущее
От: Patrick Starrenburg
Дата:
Сообщение: Re: psycopg is the new psycopg3?
Следующее
От: Daniele Varrazzo
Дата:
Сообщение: Re: 'Psycopg2.errors' not referenced in packaged