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

no encryption error, but equivalent python code works #485

Open
nick-youngblut opened this issue Dec 20, 2024 · 1 comment
Open

no encryption error, but equivalent python code works #485

nick-youngblut opened this issue Dec 20, 2024 · 1 comment

Comments

@nick-youngblut
Copy link

Works:

import psycopg2
from psycopg2.extensions import connection

def db_connect() -> connection:
    db_params = {
        'host': os.environ["DB_HOST"],
        'database': os.environ["DB_NAME"],
        'user': os.environ["DB_USERNAME"],
        'password': os.environ["DB_PASSWORD"]
        'port': '5432'
    }
    return psycopg2.connect(**db_params)

The equivalent R code does not work:

db_connect = function(){
  pool::dbPool(
    RPostgres::Postgres(),
    host = config::get("DB_HOST"),
    dbname = config::get("DB_NAME"),
    user = config::get("DB_USERNAME"),
    password = Sys.getenv("DB_PASSWORD"),
    port = 5432,
    sslmode = "disable"
  )
}

The error:

Error: connection to server at "***", port 5432 failed: FATAL:  pg_hba.conf rejects connection for host "***", user "***", database "***", no encryption

Changing sslmode to any of the other possible settings does not help.

I'm using a GCP Postgresql database.

@nick-youngblut
Copy link
Author

nick-youngblut commented Dec 20, 2024

Note: providing sslcert and sslkey results in the same error.

I can only connect with RPostgres::Postgres() if I use cloud-sql-proxy.

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

No branches or pull requests

1 participant