Is SQLAlchemy/psycopg2 connection to PostgreSQL database encrypted
<p>When I use SQLAlchemy with an external postgreSQL server, is the connection secured/encrypted?</p>

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

<p>What about psycopg2?</p>

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

<p>To have a secure connection to PostgreSQL database you can use <code>sslmode</code> parameter.</p>

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

<p><code>verify-full</code> is the highest level SSL connection validation where the client performs full SSL certificate check for the connection.</p>

<p>More info:</p>

<ul>
<li><a href="https://www.postgresql.org/docs/current/static/libpq-ssl.html" rel="nofollow">https://www.postgresql.org/docs/current/static/libpq-ssl.html</a></li>
</ul>

python postgresql sqlalchemy psycopg2