0

I want to insert longtext columns into a table,using python.

I have a columns from sql which is too long to be inserted. When I try, it doesn't throw an exception, and my max_allowed_packet is longer than the longtext column.

Example code: os.system(mysqlquery+"insert into xxx(sql,,) values(,,,)" % (sql,,))

When I shorten the sql, it can be inserted:

  • the length of sql: 162,072
  • max_packet_size:
    • max_allowed_packet: 419,4304
    • slave_max_allowed_packet: 1,073,741,824
Yaakov Bressler
  • 9,056
  • 2
  • 45
  • 69
Allen
  • 1
  • 2
  • Can you post the exact error message? Your quoted error message is nothing mysql should say, so it is hard to diagnose what exactly caused it. I am not entirely sure how you run your command, but it might be more a limit of `os.system` (see e.g. [here](https://unix.stackexchange.com/q/120642)) (which is in the general range of your 162k limit). In general, you may want to try a [python connector package](https://stackoverflow.com/q/372885) to access your database. – Solarflare Sep 25 '19 at 04:36
  • no error message,I use "os.system('mysql -h -u -p -e "insert into xxx() values()"')" in a .py file to insert. only 1 row cant be inserted, beacause its longtext column is too long,only if I shorten the longtext column,it can be inserted.how can i insert this row. – Allen Sep 25 '19 at 06:09

0 Answers0