Good afternoon
Trying to pull data from medic couchDb to my local Postgres Db (Relational) so that I can access contact registration data, which is currently not available on the medic portal. We are using the codes below on the test environment using medic-couch2pg:
The first screenshot indicates that host thatâs running couch2pg is unable to reach the postgres server because DNS lookup timed out. This is most commonly due to a typo in the url but could also be caused by faulty DNS settings.
For the second screenshot, see
database âbodadbâ does not exist
Confirm that the database exists on the postgres server and access rights have been granted to the couch2pg user.
@elijah
I can connect to the local staging Postgres db called bodadb on my local machine both using pgAdmin and CLI, no tables created so far, owner is postgres. I granted all privileges to the user postgres to bodadb
Thinking on how to grant access rights to the couch2pg user, I no user exist called couch2pg, please clarify.
@elijah
Created another user as above, couch2pg and granted access to my staging Db, still errors when I ran the code, cant access the local Postgres database
@elijah
I get the same error, despite creating another user on my local Posgres and exporting the following variables: error: password authentication failed for user âcouch2pgâ
This means the password used in the configuration file is not the one in use by postgres so authentication fails. The password for the couch2pg user can be updated using this command
I have done this many times, even used the postgres user and same error, either error: password authentication failed for user âcouch2pgâ or error: database âbodadbâ does not exist
I have seen online similar challenge, where the local Postgres Db not been seen, yet one can access it both using CL and pgAdmin. Researching on why a local DB, on localhost canât be accessed in Ubuntu server
Localhost is my machine, my laptop. I have a virtualized server, physically located within the data centre at the my workplace with a test VM, which has a public IP address and a subdomain name mapped to the IP
I replicated CouchDb instance from the CHT application on the server to my localhost instance, and this is successful.
If both postgres and couchDB are local and both services are running, they should be able to communicate via couch2pg. Iâll share recommendations for the error messages encountered:
error: password authentication failed for user âcouch2pgâ
Updating the couch2pg user password using the query below should help with this error:
ALTER USER couch2pg WITH PASSWORD 'new_password';
error: database âbodadbâ does not exist
Case sensitivity of database names in postgres could be causing this i.e. bodadb is different from bodaDB and Bodadb. The database can be created using this query:
@elijah
I think we are not communicatingâŚ
I indicated that despite creating the local Postgres Db and accessing it both using CLI and PgAdmin, running the environment variable codes brings the error above on the remote Ubuntu server
Couch2pg will attempt to connect to âbodadbâ on the server postgres rather than on your local machine. This is why the error âbodadb does not existâ is thrown. If your local machine has a public IP or domain reachable from the internet, you can substitute it for localhost in the configuration. However, note that couch2pg will not be able to connect when your laptop isnât online.
I would recommend an alternative setup where couch2pg runs on your laptop with the settings staying as they are now, pulling data from the couchdb instance which already has a publicly accessible subdomain.
@elijah
Couch2pg connects to âbodadbâ on the local postgres server, once the local postgres server has been started on my local laptop.
Thus the connection configuration variable should be fine: export POSTGRESQL_URL=postgres://couch2pg:mypassword@localhost:5432/bodadb
We are pulling data from the couchdb instance on the publicly accessible subdomain, already registered and available
Whatâs the url of the CouchDB instance running in your medic-os container?
Am attempting to connect to the couch DB url in the medic-os container using couch2pg but i keep on getting No couchdb end point Found
Thanks @elijah
i have export COUCHDB_URL=https://admin:pass@localhost:5984/medic in the terminal
but when i curl http://admin:pass@localhost:5984/medic i get {"error":"unauthorized","reason":"Name or password is incorrect."}
i tried curl http://myadminuser:myadminpass@localhost:5984/medic and it gives `