engine = create_engine(
"postgresql+pg8000://user:pass@host/dbname", client_encoding='utf8')
+.. _pg8000_ssl:
+
+SSL Connections
+----------------
+
+pg8000 accepts a Python ``SSLContext`` object which may be specified using the
+:paramref:`_sa.create_engine.connect_args` dictionary::
+
+ import ssl
+ ssl_context = ssl.create_default_context()
+ engine = sa.create_engine(
+ "postgresql+pg8000://scott:tiger@192.168.0.199:5432/test,
+ connect_args={'ssl_context': ssl_context},
+ )
+
+If the server uses an automatically-generated certificate that is self-signed
+or does not match the host name (as seen from the client), it may also be
+necessary to disable hostname checking::
+
+ import ssl
+ ssl_context = ssl.create_default_context()
+ ssl_context.check_hostname=False
+ ssl_context.verify_mode = ssl.CERT_NONE
+ engine = sa.create_engine(
+ "postgresql+pg8000://scott:tiger@192.168.0.199:5432/test,
+ connect_args={'ssl_context': ssl_context},
+ )
.. _pg8000_isolation_level:
:ref:`psycopg2_executemany_mode`
+* ``sslmode``: Controls psycopg2's behavior for encrypted connections.
+ The psycopg2 default is ``sslmode=prefer``; it will attempt an SSL
+ connection and if that fails it will fall back to an unencrypted connection.
+ ``sslmode=require`` can be used to only establish secure connections. (Other
+ modes are available. See the psycopg2 documentation for details.)
+
+
Unix Domain Connections
------------------------