Skip to content

fix(sqlalchemy): update psycopg2 driver spec in connection urls - #910

Merged
pvital merged 1 commit into
mainfrom
fix-psycopg
Oct 2, 2026
Merged

pvital merged 1 commit into
mainfrom
fix-psycopg

Conversation

@CagriYonca

Copy link
Copy Markdown
Contributor

Summary

Explicitly specify psycopg2 as the SQLAlchemy dialect driver in PostgreSQL
connection URLs and bump the psycopg2-binary lower bound to >=2.9.12.

Problem

1. SQLAlchemy 2.1 changed the default PostgreSQL driver to psycopg (v3)

With an unqualified postgresql:// URL, SQLAlchemy 2.1 now attempts to load
psycopg (v3) first. Since our test environment only installs psycopg2, this raises:

ModuleNotFoundError: No module named 'psycopg'

See: SQLAlchemy 2.1 Migration Guide

2. psycopg2-binary>=2.8.6 has no pre-built wheel for Python 3.12/3.13

On Python 3.12+, pip falls back to building from source, which fails due to
C-level incompatibilities introduced in those Python versions. Pre-built wheels
for Python 3.13 were introduced in psycopg2-binary 2.9.10. The >=2.9.12
lower bound guarantees a compatible wheel for all supported Python versions (3.9–3.14).

Changes

File Change
tests/clients/test_sqlalchemy.py postgresql:// → postgresql+psycopg2://
tests/requirements.txt psycopg2-binary>=2.8.6 → >=2.9.12
tests/requirements-pre315.txt psycopg2-binary>=2.8.6 → >=2.9.12

@CagriYonca CagriYonca self-assigned this Oct 1, 2026
@CagriYonca
CagriYonca requested a review from a team as a code owner October 1, 2026 14:41
@CagriYonca CagriYonca added the bug label Oct 1, 2026
…equirements

Signed-off-by: Cagri Yonca <cagri@ibm.com>

@pvital pvital left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks good to me.

@pvital
pvital merged commit 590d0e6 into main Oct 2, 2026
17 of 20 checks passed
@pvital
pvital deleted the fix-psycopg branch October 2, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants