pandas 连接数据库
1 import numpy as np 2 import pandas as pd 3 from sqlalchemy import create_engine 4 5 engine = create_engine("mysql+pymysql://root:100100@localhost/skill_table?charset=UTF8MB4") 6 data = pd.DataFrame(data=np.random.randint(1,100,size=(100,3)),columns=["python","Math","En"]) 7 # print(data) 8 # data.to_sql(name="pandas",con=engine,index=False) 9 r = pd.read_sql("select * from pandas limit 10",con=engine) 10 print(r)