Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fontaineajulien opened this issue Sep 5, 2024 · 7 comments · Fixed by #159 · May be fixed by #150
Closed

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

fontaineajulien opened this issue Sep 5, 2024 · 7 comments · Fixed by #159 · May be fixed by #150
Assignees

Comments

@fontaineajulien
Copy link

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

Problem

  • I think psycopg2 was not explicitly imported in 3.0.0 but since 4.0.0 it is imported in base.py

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

  • OS: Linux
  • Python version: Python 3.11.9
  • Django version: Django 4.2
  • Django-Redshift-Backend version: 4.1.1
@shimizukawa
Copy link
Member

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 ( #116 (comment) ).

@shimizukawa
Copy link
Member

I have created a pull request to fix this problem.
#150
@fontaineajulien If you have time, I would appreciate it if you could check to see if this will solve the problem.

@fontaineajulien
Copy link
Author

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

@brendenwest
Copy link

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
Copy link
Member

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
Copy link
Member

@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
Copy link
Member

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

shimizukawa added a commit that referenced this issue Oct 30, 2024
#149 Added a clear message on ImportError when the psycopg2 package cannot be found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment