簡體   English   中英

使用 pymysql 從 python 用 dataframe 替換 mysql 表時行大小太大

[英]Row size is too large while replacing mysql table with dataframe from python using pymysql

我正在使用 pymysql to_sql function 從 python 將表寫入 mysql。 我有 1000 行 200 列。

連接 mysql 的查詢如下:

engine = create_engine("mysql://hostname:password#@localhostname/dbname")
conn = engine.connect()
writing query: df.to_sql('data'.lower(),schema=schema,conn,'replace',index=False)

我收到以下錯誤:

OperationalError: (pymysql.err.OperationalError) (1118, 'Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.')

我已將列 dtypes 更改為 string 仍然超出錯誤。 請幫我解決這個錯誤。

我正在嘗試保存如下表。 在這里,我提供了一些帶有創建表查詢的列。在保存時創建表時出現錯誤。 創建表08:08:00名稱( 08:00:00文本,08:08: 08:40:00文本,08:16:00 文本,08: 08:32:00 :00 文本,08: 08:16:00 :00 文本,08: 08:24:00 :00 文本, 08:48:00文本, 08:56:00文本, 09:04:00文本, 09:12:00文本, 09:20:00文本, 09:28:00文本)

該錯誤不是由您的代碼引起的。 它是由您的 Mysql 服務器引起的

要解決此問題,請更改 mysql 服務器的 my.ini 文本文件中的 innodb_log_file_size。

然后我相信錯誤將得到修復。

innodb_log_file_size = 500M 
innodb_log_buffer_size = 800M
innodb_strict_mode = 0

嘗試在 my.cnf 中設置以下值並重新啟動 mysqld。 我希望這可以幫助你。 有關更多詳細信息,請參閱下面的鏈接。

 [mysqld]
 max_allowed_packet = 1G
 innodb_log_file_size = 2G
 innodb_log_buffer_size = 512M

有用的鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM