Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为mysql和postgres数据库启用ssl:python、sqlalchemy_Python_Mysql_Postgresql_Sqlalchemy - Fatal编程技术网

为mysql和postgres数据库启用ssl:python、sqlalchemy

为mysql和postgres数据库启用ssl:python、sqlalchemy,python,mysql,postgresql,sqlalchemy,Python,Mysql,Postgresql,Sqlalchemy,我想为我的两种类型启用ssl,mysql和postgres用于数据库连接。我的存储库中有证书文件,并使用这些证书在docker上运行代码。我正在使用以下代码: uri = "{0}://{1}@{2}:{3}/{4}".format(db_creds.get('scheme'), self._get_auth_str(db_creds.get('username'),

我想为我的两种类型启用ssl,
mysql
postgres
用于数据库连接。我的存储库中有证书文件,并使用这些证书在docker上运行代码。我正在使用以下代码:

            uri = "{0}://{1}@{2}:{3}/{4}".format(db_creds.get('scheme'),
                                                 self._get_auth_str(db_creds.get('username'),
                                                                    db_creds.get('password')),
                                                 db_creds.get('hostname'),
                                                 str(db_creds.get('port')),
                                                 db_creds.get('name'))
            ssl_args = {}
            if db == 'mysql':
                if self.config['ssloption'] == 'true':
                    self.config['ssloption'] = 'required'
                ssl_args = {
                    'ssl': {
                        'sslmode': str(self.config['ssloption'])
                    }
                }
            if db == 'warehouse':
                if self.config['ssloption'] == 'true':
                    self.config['ssloption'] = 'require'
                ssl_args = {
                    "sslmode": str(self.config['ssloption'])
                }
            self._connections[db] = create_engine(uri, connect_args=ssl_args, encoding='utf8')
我已经尝试了在线文档中提供的所有选项,但我找不到一种通用的方法来为这两种类型的数据库执行此操作。我想知道我怎样才能在这方面做到完美