sqlalchemy + pandas + 中文


 

#連接
engine = create_engine('mysql+pymysql://***:***@localhost:3306/test?charset=utf8')
# #讀取
# ret = pd.read_sql_query("select * from testtable",engine)
# print(ret)
#寫入
data0 = pd.read_excel('d:/綜合信息查詢_成交回報.xls')
print(data0)

ret2 = data0.to_sql('o32',engine,if_exists='append')
print(ret2)

 

中文

create_engine的時候在后邊加上 ?charset = utf8

http://firefish.blog.51cto.com/298258/112794/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM