#安装pymysql
pip install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple
import pymysql
import pandas as pd
connect = pymysql.connect(host='连接地址',
port=3306, # 端口
user='用户名', # 登录用户名
password = '密码', # 密码
database = '数据库名', # 默认连接哪个数据库
charset= 'utf8'
)
# 游标
cursor = connect.cursor()
sql_bd = '''select *
from `data_ctr`.person
where bd_state="在职"
and team_name !="" '''
cursor.execute(sql_bd)
bd_data = cursor.fetchall()
bd_data=pd.DataFrame(bd_data)
bd_data=bd_data.rename(columns={0:"BD姓名",1:"BD编号",2:"大区",3:"城市",4:"团队",5:"当前职位",6:"之前职位",7:"在职状态",8:"试岗日期",9:"入职日期",10:"离职日期"})
bd_data.head()