Skip to content

When the connection url does not have an explicit driver, default to the provider driver - #2425

Open
doublebyte1 wants to merge 4 commits into
geopython:masterfrom
doublebyte1:psycopg
Open

doublebyte1 wants to merge 4 commits into
geopython:masterfrom
doublebyte1:psycopg

Conversation

@doublebyte1

@doublebyte1 doublebyte1 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Currently, these are the versions being installed by the CI;

  • psycopg2 2.9.13
  • SQLAlchemy 2.1.1

In SQAlchemy 2.1, the default driver changed to psycopg. However, pygeoapi is installing psycopg2. This mistmatch between what is installed, and the default driver that SQAlchemy expects, creates the issue described on #2424

This PR addresses the issue by letting the postgresql provider fallback to the backend provider driver. This approach avoids using the default SQAlchemy driver (which is not installed) and also pinning down dependencies.

A test was also added for creating a connection using the provider driver.

Related Issue / discussion

#2424

Additional information

Dependency policy (RFC2)

  • I have ensured that this PR meets RFC2 requirements

Updates to public demo

Contributions and licensing

(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to pygeoapi. I confirm that my contributions to pygeoapi will be compatible with the pygeoapi license guidelines at the time of contribution
  • I have already previously agreed to the pygeoapi Contributions and Licensing Guidelines

@doublebyte1 doublebyte1 changed the title Psycopg When the connection url does not have an explicit driver, default to the provider driver Sep 29, 2026

@tomkralidis tomkralidis 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.

Thanks @doublebyte1. Can you fix flake8 errors in CI? Thanks.

@tomkralidis tomkralidis added this to the 0.25.0 milestone Sep 29, 2026
@tomkralidis tomkralidis added bug Something isn't working OGC API - Features OGC API - Features labels Sep 29, 2026
@webb-ben

Copy link
Copy Markdown
Member

Would the solution not be changing the driver_name in https://github.com/doublebyte1/pygeoapi/blob/0b3838011d54d01189f9cf937c557c4de35d41cb/pygeoapi/provider/sql.py#L810?

Will also note that #2251 introduced full connection strings:

data: postgresql://user:password@host:5432/db

@doublebyte1

doublebyte1 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Would the solution not be changing the driver_name in https://github.com/doublebyte1/pygeoapi/blob/0b3838011d54d01189f9cf937c557c4de35d41cb/pygeoapi/provider/sql.py#L810?

Will also note that #2251 introduced full connection strings:

data: postgresql://user:password@host:5432/db

That would be a solution, if everyone would use SQALchemy >=2.1. If someone is using an earlier version, than the driver would stil be psycog2. If we really want to be that specific, perhaps we should pin down SQAlchemy here?

SQLAlchemy

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working OGC API - Features OGC API - Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants