基本的链接查询
import pymysql
from sshtunnel import SSHTunnelForwarder
import time
import openpyxl
if __name__=='__main__':
with SSHTunnelForwarder(
('192.168.110.218',22),
ssh_password="dimarts218",
ssh_username="root",
remote_bind_address=('192.168.110.218',3306)
) as server:
db = pymysql.connect(host='127.0.0.1',port=server.local_bind_port,user='root',
password='dimarts@mysql',database='s999_tcr')
sql = 'select * from user;'
cursor = db.cursor()
cursor.execute(sql)
data = cursor.fetchall()
for x in range(len(data)):
print(data[x])
print('*****************'+'\n')
db.close()