[英]When creating models.py ,the row size too large issue is found ,how to solve this problem
How to solve this issue:如何解决这个问题:
raise errorclass(errno, errval) django.db.utils.InternalError: (1118, u'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs')
raise errorclass(errno, errval) django.db.utils.InternalError: (1118, u'Row size too large. 所用表类型的最大行大小,不包括 BLOB,为 65535。这包括存储开销,请查看手册. 您必须将某些列更改为 TEXT 或 BLOB')
can please help to solve this problem, here is the model code:请帮忙解决这个问题,这里是 model 代码:
from django.db import models
class Newsdeatils(models.Model):
news_provider_id = models.CharField(max_length=5000)
news_title = models.CharField(max_length=5000)
news_details = models.CharField(max_length=5000)
news_image = models.CharField(max_length=5000)
news_page_url = models.CharField(max_length=5000)
next_page = models.CharField(max_length=5000)
news_des = models.CharField(max_length=5000)
Just use TextField for such length requirements.只需使用TextField来满足这样的长度要求。
Usually, TextFields are not really limited to a specific length w.r.t.通常,TextFields 并不真正限于特定长度 w.r.t。 to implementation limits (regarding filesystems or the general database system used).
实现限制(关于文件系统或使用的通用数据库系统)。
TextFields
behave very similar to CharFields
in usage. TextFields
在使用上与CharFields
非常相似。 You can read about the differences here .您可以在此处阅读不同之处。
Your code would change to something like that:你的代码会变成这样:
from django.db import models
class Newsdeatils(models.Model):
news_provider_id = models.TextField(max_length=5000)
news_title = models.TextField(max_length=5000)
news_details = models.TextField(max_length=5000)
news_image = models.TextField(max_length=5000)
news_page_url = models.TextField(max_length=5000)
next_page = models.TextField(max_length=5000)
news_des = models.TextField(max_length=5000)
Please note that setting the max_length
attribute on TextField
is not required (it is when using CharField
).请注意,不需要在
TextField
上设置max_length
属性(这是在使用CharField
时)。 this max_length
attribute is also not enforced on the db-level but only used for form validation.此
max_length
属性也未在 db 级别强制执行,但仅用于表单验证。
Other things to consider in your model: Why is the news_provider_id
a CharField
? model 中要考虑的其他事项: 为什么
news_provider_id
是CharField
? should that not be a ForeignKey
?那不应该是
ForeignKey
吗? Same goes for things like the news_image
field.类似
news_image
字段的内容也是如此。 This should probably be a BinaryField
.这可能应该是
BinaryField
。
I get answer ,the issue was i had given all fields as 5000 as max_length , A table contain only limited size and i alter the column size
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.