jazzband / django-redshift-backend

Redshift database backend for Django
Apache License 2.0
83 stars 48 forks source link

Add psycopg support (v3) and remove explicit import of optional dep psycopg2 #149

Closed fontaineajulien closed 3 weeks ago

fontaineajulien commented 2 months ago

Subject: psycopg2 is an optional dependency but actually imported in base.py

Problem

Procedure to reproduce the problem

Install the package without the optional dependency on psycopg2

Error logs / results

Error loading psycopg2 module: No module named 'psycopg2'

Expected results

It would be great to be able to use psycopg (v3) or at least make psycopg2 mandatory

Environment info

shimizukawa commented 2 months ago

psycopg2 is an optional dependency but actually imported in base.py It would be great to be able to use psycopg (v3) or at least make psycopg2 mandatory

Yes, it was not good to make psycopg2 imports mandatory. Previously, it was necessary for users to be able to choose between the psycopg2 and psycopg2-binary packages, but now that it is possible to depend only on psycopg2, I would like to make the dependency mandatory. https://www.psycopg.org/docs/install.html#change-in-binary-packages-between-psycopg-2-7-and-2-8

Regarding psycopg3 support, it is not currently possible to adopt it due to the fact that django-redshift-backend depends on the django 4.0 code base ( https://github.com/jazzband/django-redshift-backend/issues/116#issuecomment-2233119734 ).

shimizukawa commented 2 months ago

I have created a pull request to fix this problem. https://github.com/jazzband/django-redshift-backend/pull/150 @fontaineajulien If you have time, I would appreciate it if you could check to see if this will solve the problem.

fontaineajulien commented 2 months ago

Looks good to me ! Thanks for the quick response, I hope you can support psycopg 3 soon

brendenwest commented 1 month ago

Is this still accurate? The 4.0.0 release added Django 4.2 support - https://github.com/jazzband/django-redshift-backend/releases/tag/4.0.0

Regarding psycopg3 support, it is not currently possible to adopt it due to the fact that django-redshift-backend depends on the django 4.0 code base ( https://github.com/jazzband/django-redshift-backend/issues/116#issuecomment-2233119734 ).

shimizukawa commented 1 month ago

Is this still accurate? The 4.0.0 release added Django 4.2 support

Yes. django-redshift-backend contains copy of Django-4.0 code to support django-4.2. https://github.com/jazzband/django-redshift-backend/tree/3697dfe43f1a1162e8e00611fbb0f52a16d80733/django_redshift_backend/_vendor/django40

shimizukawa commented 1 month ago

@fontaineajulien I found that the PR #150 I had you look at before didn't work. I've made a new PR #159, so I'd be happy if you could take a look at it. Thank you.

shimizukawa commented 3 weeks ago

I will merge and proceed with the release. If there are any problems, please let me know. Thanks!