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

Move from psycopg2 -> psycopg3 #98

Merged
merged 14 commits into from
Sep 10, 2024
Merged

Move from psycopg2 -> psycopg3 #98

merged 14 commits into from
Sep 10, 2024

Conversation

devhawk
Copy link
Contributor

@devhawk devhawk commented Sep 10, 2024

This PR moves our PG driver from psycopg2 to psycopg3. We are changing this because psycopg3 supports asyncio while psycopg2 does not.

Generally, the changes consisted of:

  • changing host for db URLs from postgresql to postgresql+psycopg (note, the package name for psycopg3 is psycopg)
  • changing PG error code field name from pgcode to sqlstate

Assorted other changes

  • changed the psycopg specific code in _notification_listener to the psycopg3 API syntax
  • cleanup exception handling in cases where we are re-raising a caught exception
  • change CI/CD workflow to complete the entire python test matrix instead of failing fast on first error

@devhawk devhawk marked this pull request as ready for review September 10, 2024 17:39
@devhawk devhawk changed the title first cut of psycopg3 support Move from psycopg2 -> psycopg3 Sep 10, 2024
@qianl15
Copy link
Member

qianl15 commented Sep 10, 2024

I updated the dependency to psycopg[c] instead of the binary one.
https://www.psycopg.org/psycopg3/docs/basic/install.html#binary-installation

The reason is that there's no available binary for my laptop (macOS, M2 chip), which may affect our users as well.

Binary packages are produced on a best-effort basis; the supported platforms depend on the CI runners available to build the packages.

Copy link
Member

@qianl15 qianl15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks good! Tests passed on my laptop (macOS + M2 chip) as well.

@devhawk devhawk merged commit 3c75b50 into main Sep 10, 2024
4 checks passed
@devhawk devhawk deleted the devhawk/psycopg3 branch September 10, 2024 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants