File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 charset : utf8
1919 echo : True
2020 str : " %(scheme)s://%(user)s:%(password)s@%(host)s:%(port)s/%(database)s?charset=%(charset)s"
21+ use_ssl : False
2122 kwargs :
2223 pool_recycle : 3600
2324healthcheck_path : /tmp/status
Original file line number Diff line number Diff line change 1- # Copyright (c) LinkedIn Corporation. All rights reserved. Licensed under the BSD-2 Clause license.
2- # See LICENSE in the project root for license information.
3-
41from sqlalchemy import create_engine
2+ import ssl
53
64connect = None
75DictCursor = None
@@ -13,8 +11,17 @@ def init(config):
1311 global DictCursor
1412 global IntegrityError
1513
16- engine = create_engine (config ['conn' ]['str' ] % config ['conn' ]['kwargs' ],
17- ** config ['kwargs' ])
14+ connect_args = {}
15+ if config ['conn' ].get ('use_ssl' ):
16+ ssl_ctx = ssl .create_default_context ()
17+ connect_args ["ssl" ] = ssl_ctx
18+
19+ engine = create_engine (
20+ config ['conn' ]['str' ] % config ['conn' ]['kwargs' ],
21+ connect_args = connect_args ,
22+ ** config ['kwargs' ]
23+ )
24+
1825 dbapi = engine .dialect .dbapi
1926 IntegrityError = dbapi .IntegrityError
2027
You can’t perform that action at this time.
0 commit comments