AkwMak AkwMak - 2 months ago 19
Python Question

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?

Answer

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:

Comments