我就废话不多说了,大家还是直接看代码吧~
import pymysql
from sshtunnel import SSHTunnelForwarder
import pymysql.cursors #以dict形式输出
def dbconnect_ssh(ssh_host,ssh_port,keyfile,ssh_user,db_host,db_name,sql,db_port,db_user,db_passwd):
with SSHTunnelForwarder(
(ssh_host, ssh_port),
#ssh_password=sshpasswd,
ssh
1