df.to_sql(name='eeshoufang', con=conn, if_exists='append', index=False, index_label=False)#df_out是处理好的数据
发生异常: OperationalError
(pymysql.err.OperationalError) (1193, "Unknown system variable 'transaction_isolation'")
(Background on this error at: https://sqlalche.me/e/14/e3q8)
File "C:\Users\86177\Desktop\爬虫\58二手房.py", line 42, in
df.to_sql(name='eeshoufang', con=conn, if_exists='append', index=False, index_label=False)#df_out是处理好的数据
MySQL错误代码:1193是未知的系统变量,你每次循环都create_engine连接一下数据库,这个资源开支很大,而且你创建数据表了没有
for ranks,genres,names,renews,estates,fonts,writers,Times in zip(rank,genre,name,renew,estate,font,writer,Time):
data={
'rank':ranks.strip(),
'genre':genres.strip(),
'name':names.strip(),
'renew':renews.strip(),
'estate':estates.strip(),
'font':fonts.strip(),
'writer':writers.strip(),
'Time':Times.strip(),
}
a.append(data)
df=pd.DataFrame(a,columns=['rank','genre','name','renew','estate','font','writer','Time'])
conn = create_engine('mysql+mysqldb://root:123456@localhost:3306/xiaoshuo?charset=utf8')
df.to_sql(name='eeshoufang', con=conn, if_exists='append', index=False, index_label=False)#df_out是处理好的数据
这个是部分代码
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!