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!
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With