我正在尝试使用pymysql库将数据批量加载到MySQL数据库。我的数据框中的某些列包含所有记录的空白值。这些空白值会产生以下错误:
pymysql.err.InternalError: (1054, "Unknown column 'nan' in 'field list'")
为处理此错误,我尝试了如下不同的选择,使我在不同列中遇到以下错误:
PATH/lib/python3.6/site-packages/pymysql/cursors.py:170: Warning: (1366, "Incorrect integer value: '' for column 'X' at row 1")
PATH/lib/python3.6/site-packages/pymysql/cursors.py:170: Warning: (1265, "Data truncated for column 'Y' at row 1")
这是一段代码:
import pymysql
conn = get_connection(credentials)
final_df = final_df.astype(object).where(pd.notnull(final_df), None)
fdf = list(final_df.itertuples(index=False, name=None))
cursor = conn.cursor()
sql = "call procedure (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
cursor.executemany(sql, fdf)
conn.commit()
cursor.close()
conn.close()
有人可以帮我解决这个问题吗?
注意: