Перечисление Mysql: невозможно обновить или вставить в таблицу, появляется ошибка «Данные усечены»Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Перечисление Mysql: невозможно обновить или вставить в таблицу, появляется ошибка «Данные усечены»

Сообщение Anonymous »

Это моя таблица:

Код: Выделить всё

CREATE TABLE `products` (
`productID` bigint NOT NULL AUTO_INCREMENT,
`designID` bigint DEFAULT '0',
`qualityID` bigint DEFAULT '0',
`brandName` varchar(50) NOT NULL,
`brandNameId` bigint NOT NULL DEFAULT '0',
`brandCounter` int NOT NULL,
`productName` varchar(255) DEFAULT NULL,
`mainCategoryId` int NOT NULL DEFAULT '0',
`subCategoryId` int NOT NULL DEFAULT '0',
`setConfiguration` int NOT NULL DEFAULT '0',
`isCombo` int NOT NULL DEFAULT '0',
`description` text,
`isLeather` tinyint(1) NOT NULL DEFAULT '0',
`isCutSizeAvailable` tinyint(1) NOT NULL DEFAULT '0',
`soleType` varchar(35) DEFAULT NULL,
`moqPairs` int NOT NULL,
`moqSets` int NOT NULL,
`minLeadTime` int NOT NULL,
`maxLeadTime` int NOT NULL,
`price` double(10,2) NOT NULL,
`sellerPrice` double(10,2) NOT NULL DEFAULT '0.00',
`transferPrice` double(15,6) DEFAULT '0.000000',
`margin` double(8,4) NOT NULL,
`marginAmt` double(7,2) DEFAULT '0.00',
`tax` double(8,4) NOT NULL DEFAULT '0.0000',
`taxAmt` double(7,2) NOT NULL DEFAULT '0.00',
`tcs` double(5,4) NOT NULL DEFAULT '0.0100',
`tcsAmt` double(7,2) NOT NULL DEFAULT '0.00',
`transferValue` double(10,2) NOT NULL DEFAULT '0.00',
`skPrice` double(10,2) NOT NULL DEFAULT '0.00',
`warrenty` varchar(256) NOT NULL,
`defImage` varchar(256) NOT NULL,
`sellerID` int NOT NULL,
`parseID` varchar(15) DEFAULT NULL,
`createdOn` int NOT NULL,
`updatedOn` int DEFAULT NULL,
`setSizes` varchar(16) DEFAULT '8',
`styleTag` varchar(50) DEFAULT NULL,
`matUpper` varchar(50) DEFAULT NULL,
`matInsock` varchar(50) DEFAULT NULL,
`matLining` varchar(50) DEFAULT NULL,
`matHeel` varchar(50) DEFAULT NULL,
`mrp` double(10,2) DEFAULT '0.00',
`searchKeywords` varchar(512) DEFAULT NULL,
`subSellerId` int DEFAULT NULL,
`isChangeRequested` tinyint(1) DEFAULT '0',
`changeRequestedOn` int DEFAULT NULL,
`isSKAssured` int NOT NULL DEFAULT '0',
`sizeChartID` int DEFAULT NULL,
`lastApprovedOn` int DEFAULT NULL,
`alterationMessage` text,
`alterationStatus` int DEFAULT NULL,
`soleTypeId` bigint DEFAULT '0',
`isSubmitted` int DEFAULT '0',
`submittedOn` int DEFAULT NULL,
`isApproved` int DEFAULT '0',
`hidden` int NOT NULL,
`approvedOn` int NOT NULL DEFAULT '0',
`isRejected` int DEFAULT '0',
`rejectedOn` int DEFAULT '0',
`rejectedRemarks` text,
`hsnCode` varchar(10) DEFAULT NULL,
`styleTagID` bigint DEFAULT '0',
`taxOnMargin` double(8,2) NOT NULL DEFAULT '0.00',
`taxOnMarginAmt` double(8,2) NOT NULL DEFAULT '0.00',
`lotSize` int NOT NULL,
`sellsType` int NOT NULL DEFAULT '0',
`sizeStandard` int NOT NULL DEFAULT '0',
`cartonType` int NOT NULL,
`multipleColors` int DEFAULT NULL,
`limitedCartonStatus` tinyint(1) NOT NULL DEFAULT '1',
`limitedCarton` int DEFAULT NULL,
`leadTime` int DEFAULT NULL,
`weight` int DEFAULT NULL,
`packaging` tinyint(1) NOT NULL DEFAULT '0',
`imported` tinyint(1) NOT NULL DEFAULT '0',
`productDescription` text,
`platform` varchar(50) NOT NULL,
`countryOrigin` varchar(20) DEFAULT NULL,
`status` int NOT NULL DEFAULT '0' COMMENT '0=>  Draft 1=>Approved 2=>InReview 3=>InApprovedReview 4=>Removed',
`currentStage` varchar(255) DEFAULT NULL,
`currentStageValue` json DEFAULT (json_object()),
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`gradeID` bigint DEFAULT NULL,
`designType` varchar(200) DEFAULT NULL,
`createdBy` bigint DEFAULT NULL,
`createdByType` varchar(200) DEFAULT NULL,
`productOwner` enum('BRAND','BRAND_AGGREGATOR_GRADE','BRAND_AGGREGATOR_DESIGN','BRAND_TRADING') NOT NULL,
PRIMARY KEY (`productID`),
UNIQUE KEY `CompositeKey` (`brandNameId`,`brandCounter`),
KEY `sellerID` (`sellerID`),
KEY `isApproved` (`isApproved`),
KEY `approvedOn` (`approvedOn`),
KEY `brandNameId` (`brandNameId`),
KEY `skPrice` (`skPrice`),
KEY `soleTypeId` (`soleTypeId`),
KEY `styleTagID` (`styleTagID`),
KEY `brandName` (`brandName`,`brandCounter`),
KEY `brandName_2` (`brandName`),
KEY `brandCounter` (`brandCounter`),
KEY `sellsType` (`sellsType`),
KEY `moqPairs` (`moqPairs`,`isApproved`,`approvedOn`),
KEY `brandCounter_2` (`brandCounter`,`moqPairs`,`isApproved`,`approvedOn`,`sellsType`),
KEY `productID_2` (`productID`,`isApproved`,`approvedOn`),
KEY `productID` (`productID`,`sellerID`,`isApproved`,`approvedOn`,`brandNameId`) USING BTREE,
KEY `brandNameId_2` (`brandNameId`,`sellerID`),
KEY `brandNameId_3` (`brandNameId`,`sellerID`,`isApproved`,`approvedOn`),
KEY `mainCategoryId` (`mainCategoryId`),
KEY `subCategoryId` (`subCategoryId`),
KEY `hid_ix` (`hidden`),
KEY `grade_index` (`gradeID`),
KEY `created_by_index` (`createdBy`),
KEY `updatedOnIdx` (`updatedOn`),
KEY `updatedAtidx` (`updated_at`),
KEY `designTypeIdx` (`designType`),
KEY `design_index` (`designID`),
KEY `quality_index` (`qualityID`),
KEY `productName_index` (`productName`),
FULLTEXT KEY `product_name_idx` (`productName`)
) ENGINE=InnoDB AUTO_INCREMENT=2066613 DEFAULT CHARSET=utf8mb3;
Я добавил «BRAND_TRADING» в перечисление в столбце ProductOwner, но при вставке или обновлении любой строки (кроме исходных значений) я получаю следующее:

Код: Выделить всё

(pymysql.err.DataError) (1265, \"Data truncated for column 'productOwner' at row 1\")\n[SQL:  INSERT INTO products (`designID`, `qualityID`, `brandName`, `brandNameId`, `brandCounter`, `productName`, `mainCategoryId`, `subCategoryId`, `setConfiguration`, `isCombo`, description, `isLeather`, `isCutSizeAvailable`, `soleType`, `moqPairs`, `moqSets`, `minLeadTime`, `maxLeadTime`, price, `sellerPrice`, `transferPrice`, margin, `marginAmt`, tax, `taxAmt`, tcs, `tcsAmt`, `transferValue`, `skPrice`, warrenty, `defImage`, `sellerID`, `parseID`, `createdOn`, `updatedOn`, `setSizes`, `styleTag`, `matUpper`, `matInsock`, `matLining`, `matHeel`, mrp, `searchKeywords`, `subSellerId`, `isChangeRequested`, `changeRequestedOn`, `isSKAssured`, `sizeChartID`, `lastApprovedOn`, `alterationMessage`, `alterationStatus`, `soleTypeId`, `isSubmitted`, `submittedOn`, `isApproved`, hidden, `approvedOn`, `isRejected`, `rejectedOn`, `rejectedRemarks`, `hsnCode`, `styleTagID`, `taxOnMargin`, `taxOnMarginAmt`, `lotSize`, `sellsType`, `sizeStandard`, `cartonType`, `multipleColors`, `limitedCartonStatus`, `limitedCarton`, `leadTime`, weight, packaging, imported, `productDescription`, platform, `countryOrigin`, status, `currentStage`, `currentStageValue`, `createdBy`, `designType`, `createdByType`, `productOwner`) VALUES (%(designID)s, %(qualityID)s, %(brandName)s, %(brandNameId)s, %(brandCounter)s, %(productName)s, %(mainCategoryId)s, %(subCategoryId)s, %(setConfiguration)s, %(isCombo)s, %(description)s, %(isLeather)s, %(isCutSizeAvailable)s, %(soleType)s, %(moqPairs)s, %(moqSets)s, %(minLeadTime)s, %(maxLeadTime)s, %(price)s, %(sellerPrice)s, %(transferPrice)s, %(margin)s, %(marginAmt)s, %(tax)s, %(taxAmt)s, %(tcs)s, %(tcsAmt)s, %(transferValue)s, %(skPrice)s, %(warrenty)s, %(defImage)s, %(sellerID)s, %(parseID)s, %(createdOn)s, %(updatedOn)s, %(setSizes)s, %(styleTag)s, %(matUpper)s, %(matInsock)s, %(matLining)s, %(matHeel)s, %(mrp)s, %(searchKeywords)s, %(subSellerId)s, %(isChangeRequested)s, %(changeRequestedOn)s, %(isSKAssured)s, %(sizeChartID)s, %(lastApprovedOn)s, %(alterationMessage)s, %(alterationStatus)s, %(soleTypeId)s, %(isSubmitted)s, %(submittedOn)s, %(isApproved)s, %(hidden)s, %(approvedOn)s, %(isRejected)s, %(rejectedOn)s, %(rejectedRemarks)s, %(hsnCode)s, %(styleTagID)s, %(taxOnMargin)s, %(taxOnMarginAmt)s, %(lotSize)s, %(sellsType)s, %(sizeStandard)s, %(cartonType)s, %(multipleColors)s, %(limitedCartonStatus)s, %(limitedCarton)s, %(leadTime)s, %(weight)s, %(packaging)s, %(imported)s, %(productDescription)s, %(platform)s, %(countryOrigin)s, %(status)s, %(currentStage)s, %(currentStageValue)s, %(createdBy)s, %(designType)s, %(createdByType)s, %(productOwner)s)]\n[parameters: {'designID': 0, 'qualityID': 0, 'brandName': 'test', 'brandNameId': '1001175', 'brandCounter': 53, 'productName': 'test 053', 'mainCategoryId': '1000020', 'subCategoryId': '1003447', 'setConfiguration': 1, 'isCombo': 0, 'description': None, 'isLeather': 0, 'isCutSizeAvailable': 0, 'soleType': None, 'moqPairs': 3, 'moqSets': 3, 'minLeadTime': 0, 'maxLeadTime': 0, 'price': 0, 'sellerPrice': 0, 'transferPrice': 0, 'margin': 0, 'marginAmt': '0.00', 'tax': 0, 'taxAmt': 0, 'tcs': '0.0100', 'tcsAmt': '0.00', 'transferValue': 0, 'skPrice': 0, 'warrenty': 1, 'defImage': 'https://bijnis.s3.amazonaws.com/PRODUCTION/uploads/uploadfile_1-2e496e1b-d002-40f9-bdd0-030e3e329203.jpg', 'sellerID': '1490486208', 'parseID': None, 'createdOn': 1715713458, 'updatedOn': None, 'setSizes': '8', 'styleTag': None, 'matUpper': None, 'matInsock': None, 'matLining': None, 'matHeel': None, 'mrp': 0, 'searchKeywords': '', 'subSellerId': None, 'isChangeRequested': '0', 'changeRequestedOn': None, 'isSKAssured': '0', 'sizeChartID': 0, 'lastApprovedOn': None, 'alterationMessage': None, 'alterationStatus': None, 'soleTypeId': '0', 'isSubmitted': 1, 'submittedOn': 1715713458, 'isApproved': 1, 'hidden': 0, 'approvedOn': 1715713458, 'isRejected': '0', 'rejectedOn': 0, 'rejectedRemarks': None, 'hsnCode': '878776', 'styleTagID': '0', 'taxOnMargin': '0.00', 'taxOnMarginAmt': '0.00', 'lotSize': 3, 'sellsType': 1, 'sizeStandard': 1, 'cartonType': 0, 'multipleColors': 1, 'limitedCartonStatus': 0, 'limitedCarton': None, 'leadTime': None, 'weight': 0, 'packaging': '0', 'imported': '0', 'productDescription': None, 'platform': 'web', 'countryOrigin': 'India', 'status': 1, 'currentStage': 'LAUNCHED', 'currentStageValue': '{\"launched\": {\"launchedBy\": \"1490488311\", \"launchedOn\": \"2024-05-15 00:34:18.318600\"}, \"productApproved\": [{\"approvedBy\": \"1490488311\", \"approvedOn\": \"2024-05-15 00:34:18\"}]}', 'createdBy': '1490488311', 'designType': None, 'createdByType': 'Seller', 'productOwner': 'BRAND_TRADING'}]\n(Background on this error at:  https://sqlalche.me/e/14/9h9h)
Я пробовал следующие подходы, основанные на ответах на аналогичные проблемы:
  • изменение столбца как VARCHAR(30), но проблема все еще сохраняется (та же ошибка)
  • создание нового столбца с именем productOwnerNew (пробовано как с VARCHAR, так и с перечислением с новым значением) и выгрузка данных из productOwner, здесь я смог добавить/ отредактируйте строку, но когда я снова изменил имя столбца ProductOwnerNew -> ProductOwner и ProductOwner -> ProductOwnerOld, я не смог добавить/отредактировать столбец как «BRAND_TRADING» (пробовал и с другими случайными строками) и получил ту же ошибку, но, что интересно, я был смог добавить/редактировать столбец теперь productOwnerOld
  • проверил триггеры, ограничения, FK: никаких изменений в столбце нет, индекс был, но я удалил его на всякий случай, прежде чем делать вышеизложенное подходит
  • проверил sql_mode, он установлен как ''
PS:
Пример, который я привел ранее ошибка отображалась через sqlAlchemy (эта ошибка не из-за SQLAlchemy), я получил ту же ошибку при непосредственном обновлении таблицы, и я использую это:

Код: Выделить всё

product_record = Products(**request_data)
dbw_conn.add(product_record)
dbw_conn.flush()
а это request_data здесь:

Код: Выделить всё

{'sellerID': '1490486208', 'setConfiguration': 1, 'isCombo': 0, 'brandName': 'test', 'brandNameId': '1001175', 'productOwner': 'BRAND_TRADING', 'sizeStandard': 1, 'brandCounter': 53, 'productName': 'test 053', 'sellsType': 1, 'approvedOn': 1715702816, 'rejectedOn': 0, 'mainCategoryId': '1000020', 'subCategoryId': '1003447', 'lotSize': 3, 'moqPairs': 3, 'moqSets': 3, 'limitedCartonStatus': 0, 'platform': 'web', 'multipleColors': 1, 'createdOn': 1715702794, 'createdBy': '1490488311', 'createdByType': 'Seller', 'productDescription': None, 'packaging': None, 'countryOrigin': 'India', 'weight': 0, 'hsnCode': '878776', 'defImage': 'https://bijnis.s3.amazonaws.com/PRODUCTION/uploads/uploadfile_1-2e496e1b-d002-40f9-bdd0-030e3e329203.jpg', 'sellerPrice': 0, 'price': 0, 'skPrice': 0, 'taxAmt': 0, 'tax': 0, 'transferValue': 0, 'transferPrice': 0, 'mrp': 0, 'searchKeywords': '', 'sizeChartID': 0, 'status': 1, 'isApproved': 1, 'currentStage': 'LAUNCHED', 'isSubmitted': 1, 'submittedOn': 1715702818, 'currentStageValue': {'launched': {'launchedBy': '1490488311', 'launchedOn': '2024-05-14 21:36:59.032219'}, 'productApproved': [{'approvedBy': '1490488311', 'approvedOn': '2024-05-14 21:37:00'}]}}
ошибка при прямом обновлении в таблице: данные для столбца ProductOwner в строке 1 обрезаны

Подробнее здесь: https://stackoverflow.com/questions/784 ... ated-error
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»