- # 打开控制台⾯板端⼝
- [root@hcss-ecs-e083 ~]# firewall-cmd --zone=public
- --add-port=7500/tcp --permanent
- # 打开frp服务端⼝
- [root@hcss-ecs-e083 ~]# firewall-cmd --zone=public
- --add-port=7000/tcp --permanent
- # 打开⼀组客户端⼝
- [root@hcss-ecs-e083 ~]# firewall-cmd --zone=public
- --add-port=6000-6100/tcp --permanent
- # 加载防⽕墙更新
- [root@hcss-ecs-e083 ~]# firewall-cmd --reload
- [root@hcss-ecs-e083 ~]# ls -l
- frp_0.33.0_linux_amd64/frps*
- -rwxrwxr-x 1 yuanyu yuanyu 12976128 Apr 27 2020
- frp_0.33.0_linux_amd64/frps
- -rw-rw-r-- 1 yuanyu yuanyu 4639 Apr 27 2020
- frp_0.33.0_linux_amd64/frps_full.ini
- -rw-rw-r-- 1 yuanyu yuanyu 114 Jul 18 21:41
- frp_0.33.0_linux_amd64/frps.ini
- [root@hcss-ecs-e083 ~]# vim
- ~/frp_0.33.0_linux_amd64/frps.ini
- ---------------------------------------------------
- -----------
- # 服务名称
- [common]
- # 服务端⼝
- bind_port = 7000
- # 控制台⾯板账号
- dashboard_user=xxxxxx
- # 控制台密码
- dashboard_pwd=xxxxxxx
- # 控制台端⼝
- dashboard_port=7500
- # 代理标识
- token=xxxxxxxx
- [root@hcss-ecs-e083 ~]# ls -l
- frp_0.33.0_linux_amd64/frpc*
- -rwxrwxr-x 1 yuanyu yuanyu 10629120 Apr 27 2020
- frp_0.33.0_linux_amd64/frpc
- -rw-rw-r-- 1 yuanyu yuanyu 7575 Apr 27 2020
- frp_0.33.0_linux_amd64/frpc_full.ini
- -rw-rw-r-- 1 yuanyu yuanyu 126 Apr 27 2020
- frp_0.33.0_linux_amd64/frpc.ini
- # 服务器名称
- [common]
- # 服务器ip
- server_addr = x.x.x.x
- # 服务器端⼝
- server_port = 7000
- # 代理标识
- token=xxxxxxx
- # 被代理的主机名称,不允许和其他重复
- [被代理主机名称xxx]
- # 代理服务类型
- type = tcp
- # 本地ip
- local_ip = 127.0.0.1
- # 本地被代理的端⼝
- local_port = 22
- # 选择代理后的端⼝
- remote_port = ⾃选端⼝xxxxxxx60000
- pip3 config set global.index-url
- https://pypi.tuna.tsinghua.edu.cn/simple
- yum -y install sqlalchemy
- pip3 install pandas
- import pandas as pd
- from sqlalchemy import create_engine
- class Python_Mysql(object):
- def __init__(self):
- print("test")
- def getEngine(seft):
- host=input("sign mysql server
- host:")
- username=input("sign mysql
- username:")
- password=input("sign mysql
- password:")
- databasename=input("sign database
- name:")
- port=input("sign mysql port:")
- engine=create_engine(f"mysql+pymysql://{username}:
- {password}@{host}:{port}/{databasename}")
- return engine
- def querySql(self,conn):
- sql=input("sign your sql:")
- return
- pd.read_sql(sql=sql,con=conn)
- if __name__=="__main__":
- demo=Python_Mysql()
- #sql=input("sign sql:")
- # sql="select * from user"
- rs=demo.querySql(demo.getEngine())
- print(rs)
- pip3 config set global.index-url
- https://pypi.tuna.tsinghua.edu.cn/simple
- yum -y install pandas
- yum -y install pymysql
- >>> import pandas as pd
- >>> import pymysql
- >>> conn=pymysql.connect(
- ... host='10.1.1.100',
- ... user='zhangmin',
- ... password='zhangmin',
- ... database='test',
- ... port=3306
- ... )
- >>> conn
- <pymysql.connections.Connection object at
- 0x7f9e24ba2c88>
- >>> cursor=conn.cursor()
- >>> cursor
- <pymysql.cursors.Cursor object at 0x7f9e24ba2668>
- >>> sql="select * from user"
- >>> cursor.excute(sql)
- Traceback (most recent call last):
- File "
" , line 1, in <module> - AttributeError: 'Cursor' object has no attribute
- 'excute'
- >>> cursor.execute(sql)
- 3
- >>> cursor.description
- (('id', 3, None, 11, 11, 0, False), ('username',
- 253, None, 180, 180, 0, False), ('password', 253,
- None, 180, 180, 0, False))
- >>> desc=cursor.description
- >>> res
- 3
- >>> res=cursor.fetchall()
- >>> res
- ((1, 'aaa', '123'), (8, 'baba', 'pipi'), (20,
- 'aaaaaaaa', 'bbbbbbbb'))
- >>> desc
- (('id', 3, None, 11, 11, 0, False), ('username',
- 253, None, 180, 180, 0, False), ('password', 253,
- None, 180, 180, 0, False))
- >>> [item[0] for item in desc]
- ['id', 'username', 'password']
- >>> col=[item[0] for item in desc]
- >>> df=pd.DataFrame(res,columns=col)
- >>> df
- id username password
- 0 1 aaa 123
- 1 8 baba pipi
- 2 20 aaaaaaaa bbbbbbbb