import pandas as pd
from sqlalchemy import create_engine
engine = create_engine(‘mysql+pymysql://root:147369@localhost:3306/mydb’)
sql = ‘’’
select * from employee;
‘’’
df = pd.read_sql_query(sql, engine)
print(df)
df = pd.DataFrame({‘id’:[1,2,3,4],‘num’:[12,34,56,89]})
df.to_sql(‘mydf’, engine, index= False)
print(‘Read from and write to Mysql table successfully!’)