mysql- Mysql2::Error: Data too long for column 'description' at row 1

匿名 (未验证) 提交于 2019-12-03 01:36:02

问题:

I built a scraper and it doesn't seem to like my description length. I altered the column to varchar(500) but no dice. I think I need to convert to text, but I am not sure how to. Does that make sense in my case? Thanks!

Error-

Mysql2::Error: Data too long for column 'description' at row 1: INSERT INTO sammiches (country, created_at, description, image, name, updated_at) VALUES ('Italy', '2013-05-03 01:10:08', 'In Italy, panino is the word for a sandwich made from bread other than sliced bread, in which case Italians call it a tramezzino or porco. Examples of bread types used are ciabatta, rosetta and baguette. The bread is cut horizontally and filled with deli ingredients such as salami, ham, cheese, mortadella, or other food, and sometimes served warm after having been pressed by a warming grill. In the United States, United Kingdom and Canada, the term panini has been adopted to refer to a pressed and toasted sandwich; there is widespread availability and use of sandwich presses, often known as \"panini presses\" or \"toasted sandwich makers.\"', '/wiki/File:Italian_Sandwich.jpeg', 'Panini', '2013-05-03 01:10:08') (ActiveRecord::StatementInvalid)

回答1:

Your length is about 650 characters now. Try to increase more.



回答2:

the type VARCHAR() just can go up to 255 characters. Try TEXT instead.

http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html



回答3:

-- if a table restrict you to insert data becasue the length is smaller and -- you realy want to get rid of the restriction -- do this

show global variables like '%sql%mode'; set global sql_mode='NO_ENGINE_SUBSTITUTION'; -- also set it here -- /etc/my.cnf -- http://dev.mysql.com/doc/refman/5.6/en/sql-mode.html



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!