jdelic / django-dbconn-retry

Patches Django to reconnect on a failed database connection once before failing. Helping with running Django ORM through HAProxy, for example.
BSD 3-Clause "New" or "Revised" License
76 stars 25 forks source link

`psycopg` (psycopg 3) support #40

Closed rooterkyberian closed 1 month ago

rooterkyberian commented 1 year ago

psycopg3 is not supported at the moment;

Seems like this (and similar issues in the future) can be avoided if with self.wrap_database_errors: will be used inside try-except instead of outside. I can create a PR to that effect if it makes sense to you as well :)

esseti commented 7 months ago

is this fixed, or how can we use this package with the version 3 of psycopg?

rooterkyberian commented 7 months ago

IIRC only adjustment necessary was in https://github.com/jdelic/django-dbconn-retry/blob/4110c1a36e54e45bfabd51df28957442cfe938a3/django_dbconn_retry/apps.py#L18-L25

i.e. you can monkey patch it like this:

import psycopg
import django_dbconn_retry.apps
django_dbconn_retry.apps._operror_types += (psycopg.OperationalError, )
rooterkyberian commented 7 months ago

I see there is PR with fix here: https://github.com/jdelic/django-dbconn-retry/pull/42

jdelic commented 1 month ago

v0.1.8 includes these changes. Thank you.