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

Parse conninfo string in osm2pgsql-replication #1645

Merged
merged 1 commit into from
Mar 1, 2022

Conversation

rustprooflabs
Copy link
Contributor

This is an attempt to fix #1643. This updates osm2pgsql-replication to parse a conninfo string passed to the -d option when psycopg3 is used. If pyscopg2 is installed on the system it fails in its current state. I glanced through the psycopg2 docs and do not see a similar functionality to what is available in the new version. If this looks like a decent direction to head for this fix I can work on making this change not fail with psycopg2.

This now works.

osm2pgsql-replication status -d postgresql://myuser:mypassword@myhost/pgosm
Using replication service 'http://download.geofabrik.de/north-america/us/district-of-columbia-updates', which is at sequence 3257 ( 2022-02-24T21:21:27Z )
Replication server's most recent data is 1 day(s) 2 hour(s) 8 minute(s) old
Local database is 29 sequences behind the server, i.e. 4 week(s) 0 day(s) 23 hour(s) 59 minute(s)
Local database's most recent data is 4 week(s) 2 day(s) 2 hour(s) 8 minute(s) old

@lonvia
Copy link
Collaborator

lonvia commented Feb 27, 2022

Looks like parsing the DSN needs to be done in a completely different way in psycopg2 and psycopg3. So that will only work with lots of fiddeling, I'm afraid.

What works for both is the dsn parameter for connect. So I would rather check if the dbname parameter looks like a connection string (presence of = or ://) and then feed it in as a DSN.

@rustprooflabs
Copy link
Contributor Author

This now uses the simpler approach of checking for those string parts. This seems to work with psycopg2 and psycopg3 now.

@lonvia
Copy link
Collaborator

lonvia commented Feb 27, 2022

That looks much simpler. :) Do you prefer to squash the commits before I merge?

@lonvia lonvia merged commit 464f3b2 into osm2pgsql-dev:master Mar 1, 2022
@lonvia
Copy link
Collaborator

lonvia commented Mar 1, 2022

Bother, I thought I had already pressed the merge button. Thanks for looking into this.

@rustprooflabs rustprooflabs deleted the replication-conninfo branch March 3, 2022 23:19
@rustprooflabs
Copy link
Contributor Author

Thank you!

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.

osm2pgsql-replication not working with conninfo string
2 participants