pandas把数据保存到数据库

import pandas as pd

from sqlalchemy import create_engine

engine = create_engine('mysql://root:123456@localhost/music?charset=utf8')

con = engine.connect()

pd.set_option('expand_frame_repr', False)

kuwo = pd.read_excel('文本路径')

video = pd.read_excel('文本路径')

kuwo.to_sql(name='数据库名字', con=con, if_exists='append')

con.close()

扫描二维码关注公众号,回复: 6748766 查看本文章

猜你喜欢

转载自blog.csdn.net/king_26852/article/details/87280551