Python 3.x 如何指定tls版本';TLSv1.2';使用Python peewee连接到MySQL时
如何使用Python的peewee库连接到MySQL数据库,同时指定tls版本['TLSv1.1','TLSv1.2'],如MySQL文档所示 我可以使用MySQL.connector成功连接到MySQL数据库,如下所示:Python 3.x 如何指定tls版本';TLSv1.2';使用Python peewee连接到MySQL时,python-3.x,ssl,tls1.2,peewee,mysql-connector-python,Python 3.x,Ssl,Tls1.2,Peewee,Mysql Connector Python,如何使用Python的peewee库连接到MySQL数据库,同时指定tls版本['TLSv1.1','TLSv1.2'],如MySQL文档所示 我可以使用MySQL.connector成功连接到MySQL数据库,如下所示: import mysql.connector config = {'database': 'dbname', 'user': 'username_so', 'password': 'psswrd', 'host': 'maria####-##-###-##.###.#
import mysql.connector
config = {'database': 'dbname',
'user': 'username_so',
'password': 'psswrd',
'host': 'maria####-##-###-##.###.####.com',
'port': 3306,
'tls_versions': ['TLSv1.1', 'TLSv1.2']}
cnx = mysql.connector.connect(**config)
cnx.close()
但是,在建立连接时,我无法将“tls_versions”参数传递给peewee。因此,我收到一条错误消息:
配置不当:未安装MySQL驱动程序
我很确定问题在于在peewee中指定tls版本,因为在添加额外的“tls_versions”参数之前,我在mysql.connector中收到了相同的错误消息
以下是我在peewee中使用的失败代码:
db = MySQLDatabase(**config)
db.get_tables() # This function and any other that connects to the db gets the same error message specified above
我的设置:
Linux
Python 3.7
peewee==3.13.3
mysql-connector-python==8.0.21
当我回答您的github问题时: 您需要使用
playhouse.mysql\u ext.MySQLConnectorDatabase
来使用mysql连接器驱动程序进行连接。那会解决你的问题