[英]When creating models.py ,the row size too large issue is found ,how to solve this problem
如何解決這個問題:
raise errorclass(errno, errval) django.db.utils.InternalError: (1118, u'Row size too large. 所用表類型的最大行大小,不包括 BLOB,為 65535。這包括存儲開銷,請查看手冊. 您必須將某些列更改為 TEXT 或 BLOB')
請幫忙解決這個問題,這里是 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)
只需使用TextField來滿足這樣的長度要求。
通常,TextFields 並不真正限於特定長度 w.r.t。 實現限制(關於文件系統或使用的通用數據庫系統)。 TextFields
在使用上與CharFields
非常相似。 您可以在此處閱讀不同之處。
你的代碼會變成這樣:
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)
請注意,不需要在TextField
上設置max_length
屬性(這是在使用CharField
時)。 此max_length
屬性也未在 db 級別強制執行,但僅用於表單驗證。
model 中要考慮的其他事項: 為什么news_provider_id
是CharField
? 那不應該是ForeignKey
嗎? 類似news_image
字段的內容也是如此。 這可能應該是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.