ochaer1
ochaer1

Reputation: 23

Python problem connecting to Heroku PostgreSQL - SSL issue

I am trying to create a connection to a Heroku PostgreSQL database via Python. I am using Windows10 with Python 3.6.8 and PostgreSQL 9.6.

I took this piece of code from "http://andyfiedler.com/2016/10/connecting-to-heroku-postgres-in-python"

import psycopg2

import subprocess

proc = subprocess.Popen('heroku config:get DATABASE_URL -a heroku_app', stdout=subprocess.PIPE, shell=True)
db_url = proc.stdout.read().decode('utf-8').strip() + '?sslmode=require'
heroku_conn = psycopg2.connect(db_url)

When I run that code, I get the error:

OperationalError: could not create SSL context: No such process

Searching around suggests that I need to install PostgreSQL with the "--with-openssl" option. Or, with SSL compiled in.

How do I do this in Windows10? Or, is there another way to get this to work? Thank you!

Upvotes: 2

Views: 959

Answers (1)

bignose
bignose

Reputation: 32309

PostgreSQL's client library, named “libpq”, has optional support for SSL. You need the programs that will connect to PostgreSQL, to have that support enabled when the program was built.

You can get the official PostgreSQL packages for Windows.

Upvotes: 1

Related Questions