我尝试过使用Peewee和sshtunnel连接到远程mysql数据库:
with SSHTunnelForwarder(
('server.pt', 9922),
ssh_password="pass_ssh",
ssh_username="user_ssh",
remote_bind_address=('localhost', 3306)) as server:
myDB = pw.MySQLDatabase("dbname", user="db_user", passwd="db_pass")
但我有个错误
^{pr2}$你能帮帮我吗?在
您可能需要包括从
server
对象绑定隧道的本地端口:myDb = pw.MySQLDatabase("dbname", host="localhost", port=server.local_bind_port, user="db_user", passwd="db_pass")
有关示例,请参见here。在
相关问题 更多 >
编程相关推荐