win+R ==> cmd
jupyter notebook
new python3
from sqlalchemy import create_engine
# 创建数据库连接
engine = create_engine('mysql+pymysql://root:123456@localhost:3306/my_db')
# 执行查询
import pandas as pd
query = "SELECT * FROM pythonchinese"
result = pd.read_sql(query, con=engine)
# 输出结果
print(result)
在单位
import pandas as pd
a = %sql select * from pythonchinese order by dat_acc
b= a.DataFrame()
for i in b["zwchae"]:
if i ==0:
b["zwchae"][i]="正常"
print(b["zwchae"][i])
else:
print("不正常")