Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect PyCharm to a Heroku postgres database

Trying to connect to our Heroku database via PyCharm which understandably requires SSL.

Is there a way to do this using the built in SSL for *.herokuapp.com?

Essentially trying to work out how to get the .pem files for PyCharm (specifically CA file, Client cert file, Client key file).

Thanks!

like image 331
Bryce York Avatar asked Oct 28 '15 00:10

Bryce York


People also ask

How do I connect to my Heroku Postgres database?

The quickest method is right through your app dashboard on Heroku. Go to your app page, from here you can click the "Heroku Postgres" link, that will take you to the database settings page at data.heroku.com. You can also go directly to https://data.heroku.com/ and choose your correct database.

How do I use Heroku Postgres in Python?

PostgreSQL Python: Connect To HerokuPostgres Databaseimport psycopg2, os # read database connection url from the enivron variable we just set. DATABASE_URL = os. environ. get('DATABASE_URL') con = None try: # create a new database connection by calling the connect() function con = psycopg2.


1 Answers

There is no need to configure the files. Just append the following to the automatically generated url:

?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

So the correct url will be:

jdbc:postgresql://host:port/database?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

It does not seem to matter if you check SSL or not. The param ssl=true will force an ssl connection.

like image 86
Arctelix Avatar answered Sep 23 '22 22:09

Arctelix