Skip to content

fix: drop the hard psycopg2 dependency - #71

Merged
desaintmartin merged 1 commit into
mainfrom
fix/drop-psycopg2-dependency
Oct 20, 2026
Merged

desaintmartin merged 1 commit into
mainfrom
fix/drop-psycopg2-dependency

Conversation

@desaintmartin

@desaintmartin desaintmartin commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Chartreuse imports no database driver. SQLAlchemy selects the driver from the dialect in the URL. The hard psycopg2 dependency forced a compiled psycopg2 into project images that migrate to psycopg 3.

  • Remove psycopg2 from dependencies and from requirements.txt.
  • Add the extras chartreuse[psycopg2] and chartreuse[psycopg]. The test and dev extras keep psycopg2 for the e2e suite.
  • Build the database URL with sqlalchemy.engine.URL.create. Special characters in the user or the password (@, :, /, %) no longer break the URL.
  • Double % when writing alembic.ini. ConfigParser and Alembic interpolate %, and an escaped password contains %XX.
  • Release as 7.1.0. It replaces 8.0.0 and keeps its Python 3.14 minimum. The Helm chart requires the same major version as the package, so Chartreuse stays on major 7. The changelog merges the 8.0.0 entry into 7.1.0.

Driver selection

Project image dialect: postgresql uses
SQLAlchemy 2.0 psycopg2
SQLAlchemy 2.1 psycopg (3)

A project can force a driver with dialect: postgresql+psycopg. No change is needed in the configuration file format.

Impact

A project that got psycopg2 only through Chartreuse must add a driver. It can use one of the new extras.

Tests

  • Unit tests: 106 passed (Python 3.14, SQLAlchemy 2.0.43, psycopg2).
  • Manual check: SQLAlchemy 2.1.5 with chartreuse[psycopg] and no psycopg2 installed. create_engine on the built URL selects the psycopg driver.

@desaintmartin
desaintmartin force-pushed the fix/drop-psycopg2-dependency branch from eabfac0 to 30f6ab1 Compare October 19, 2026 12:01
@fregogui
fregogui self-requested a review October 19, 2026 14:50
Comment thread CHANGELOG.md
Chartreuse imports no database driver. SQLAlchemy selects the driver
from the dialect: "postgresql" means psycopg2 with SQLAlchemy 2.0 and
psycopg (3) with SQLAlchemy 2.1. The hard psycopg2 dependency forced a
compiled psycopg2 into images that migrate to psycopg 3.

- Remove psycopg2 from the dependencies.
- Add the extras "psycopg2" and "psycopg" to install a driver.
- Build the URL with URL.create, so special characters in the user or
  the password do not break it.
- Double "%" when writing alembic.ini, because ConfigParser and Alembic
  interpolate it.
- Release as 7.1.0, with the Python 3.14 minimum from 8.0.0. The Helm
  chart requires the same major version as the package.
@desaintmartin
desaintmartin force-pushed the fix/drop-psycopg2-dependency branch from 30f6ab1 to 7f17b4b Compare October 20, 2026 05:35
@desaintmartin
desaintmartin merged commit 81462fd into main Oct 20, 2026
6 checks passed
@desaintmartin
desaintmartin deleted the fix/drop-psycopg2-dependency branch October 20, 2026 05:37
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