Pandas Write table to MySQL: “unable to rollback”

前端 未结 4 1277
遥遥无期
遥遥无期 2021-01-12 13:53

I need help to get this working. I have a pd.DataFrame (df), which I need to load to a MySQL database. I don\'t understand what the error message means and how

4条回答
  •  长发绾君心
    2021-01-12 14:47

    For me this was fixed using

    MySQLdb.connect("127.0.0.1","root","","db" )
    

    instead of

    MySQLdb.connect("localhost","root","","db" )
    

    and then

    df.to_sql('df',sql_cnxn,flavor='mysql',if_exists='replace', chunksize=100)
    

提交回复
热议问题