AkwMak
AkwMak

Reputation: 167

Is SQLAlchemy/psycopg2 connection to PostgreSQL database encrypted

When I use SQLAlchemy with an external postgreSQL server, is the connection secured/encrypted?

from sqlalchemy.engine import create_engine engine = create_engine('postgresql://scott:tiger@ip:5432/mydatabase')

What about psycopg2?

Upvotes: 4

Views: 7270

Answers (1)

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83408

Your connection string does not indicate secure connection. However, sometimes connection might be secure nevertheless, but it is unlikely.

To have a secure connection to PostgreSQL database you can use sslmode parameter.

 engine = create_engine('postgresql://scott:tiger@ip:5432/mydatabase?sslmode=verify-full')

verify-full is the highest level SSL connection validation where the client performs full SSL certificate check for the connection.

More info:

Upvotes: 5

Related Questions