2020
12-07
12-07
python3 使用ssh隧道连接mysql的操作
我就废话不多说了,大家还是直接看代码吧~importpymysqlfromsshtunnelimportSSHTunnelForwarderimportpymysql.cursors#以dict形式输出defdbconnect_ssh(ssh_host,ssh_port,keyfile,ssh_user,db_host,db_name,sql,db_port,db_user,db_passwd):withSSHTunnelForwarder((ssh_host,ssh_port),#ssh_password="sshpasswd",ssh_pkey=keyfile,ssh_username=ssh_user,remote_bind_address=(db_host,db_port))as...
继续阅读 >