Accessing cockroachcloud db from python app running in Heroku

Hi,

Does any know if a python app running in Heroku can access cockroachcloud DB using the psycopg2?

I just updated my Heroku app to point to the cockroachcloud DB, but it is unable to connect. The same app runs fine on a non-Heroku service.

Thanks,
Saqib

I think we can get this figured out. Can you post the code that you’re using to connect (with sensitive details redacted, of course)? Also, are you trying to connect to a free-tier cluster or a dedicated cluster?

Hi @kernfeld-cockroach .

I am using the following syntax:
postgres://<username>:<password>@<globalhost>:26257/<cluster-name>.bank?sslmode=verify-full&sslrootcert=<certs_directory>/cc-ca.crt

as described here:

And I am using the free-tier cluster.

Thanks,
Saqib

All right, I think I have it. I was just now able to connect to a free-tier cluster from psycopg2. The trick is that you have to URL-encode the equals sign as %3D. I notice you don’t have the cluster option in your connection string, so you’ll need to add the one that you get from the “connect” dialog box on the Cockroach Cloud website. Sorry that this experience is so bumpy, we’re prioritizing making it better!

"postgres://myuser:mypassword@free-tier8.gcp-europe-west1.crdb.io:26257/defaultdb?sslmode=verify-full&sslrootcert=/path/to/my/cc-ca.crt&options=--cluster%3Dmy-cluster-name"