diff options
author | Gord Thompson <gord@gordthompson.com> | 2021-05-23 17:44:13 -0600 |
---|---|---|
committer | Gord Thompson <gord@gordthompson.com> | 2021-05-23 17:44:13 -0600 |
commit | 7c2c5ccf285333439df523be4ab419fa3c629871 (patch) | |
tree | 829e2210835d18239ab5226c1357781120cfd737 /lib/sqlalchemy/dialects/postgresql/pg8000.py | |
parent | b2ab2bbf4faf508b3fa5749969019203a702786f (diff) | |
download | sqlalchemy-7c2c5ccf285333439df523be4ab419fa3c629871.tar.gz |
Add SSL connection info for psycopg2 and pg8000
Change-Id: I8ead04dd572f0c0020c226254543eb7d93876ee4
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/pg8000.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/pg8000.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py index d999cdf6f..e39f61ddc 100644 --- a/lib/sqlalchemy/dialects/postgresql/pg8000.py +++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py @@ -39,6 +39,33 @@ passed to :func:`_sa.create_engine` using the ``client_encoding`` parameter:: 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: |