[英]fetch() retrieved data in JS (React) throws error with no apparent reason
[英]getting error 2064 for no apparent reason
好的,所以我正在将值从 nodejs 上传到 mysql 表,但我收到错误 1064,就好像它的格式错误一样,但我找不到问题。 这是查询:
`"INSERT INTO product_specifics (product_spec_url, product_name, product_price, product_date, product_water_resistan,
product_ip_rating, product_battery_capacity, product_fast_charging, product_brand, product_image_url,
product_screen_resolution, product_screen_width, product_pixel_per_inch, product_processor,roduct_processor_name,
product_ram, product_storage, product_storage_expandable, product_rear_camera_resolution,
product_rear_camera_number,product_front_camera_resolution, product_front_camera_number,
product_operating_system_name, product_operating_system_version, product_wifi_standards,product_bluetooth_avaible,
product_bluetooth_version, product_nfc_avaible, product_audio_jack, product_face_unlock, product_safe_face_unlock)
VALUES
('https://gadgets.ndtv.com/acer-liquid-z6-plus-3730','Acer Liquid Z6 Plus','null','2016-08-15','0','null','4080',
'null','Acer','https://drop.ndtv.com/TECH/product_database/images/831201661028PM_635_acer_liquid_z6_plus.jpeg?downsize=*:180&output-quality=80',
'1920x1080 pixels','5.5','0','1.3GHz octa-core','MediaTek MT6753','3','32','1','13','1','5','1','Android','6',
'802.11 b/g/n','1','null','0','3.5mm','0','0');"`
这是代码
const mysql = require('mysql');
var con = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'myDB'
});
con.connect(function(err) {
if (err) throw err;
console.log("You are now connected with mysql database...");
});
const uploader = function(potusParse) {
var lenght = potusParse.length;
for (let i = 0; i < lenght; i++) {
var object = potusParse[i];
con.query("big buoy above", function (err, result) {
if (err) throw err;
console.log("1 record inserted");
});
}
}
potusParse 是一个来自另一个模块的参数,它是一个巨大的对象数组,它在这里: https : //pastebin.com/VFEWNuXx ; 这是创建表的查询:
CREATE TABLE product_specifics (
product_spec_url VARCHAR (255),
product_name VARCHAR(255),
product_price INT(255),
product_date DATE,
product_water_resistan INT(1),
product_ip_rating VARCHAR(255),
product_battery_capacity INT(16),
product_fast_charging VARCHAR(255),
product_brand VARCHAR(255),
product_image_url VARCHAR(255),
product_screen_resolution VARCHAR(255),
product_screen_width INT(8),
product_pixel_per_inch INT(16),
product_processor VARCHAR(255),
product_processor_name VARCHAR(255),
product_ram INT(8),
product_storage INT(16),
product_storage_expandable INT(255),
product_rear_camera_resolution INT(8),
product_rear_camera_number INT(8),
product_front_camera_resolution INT(8),
product_front_camera_number INT(1),
product_operating_system_name VARCHAR(64),
product_operating_system_version INT(16),
product_wifi_standards VARCHAR(255),
product_bluetooth_avaible INT(1),
product_bluetooth_version INT(16),
product_nfc_avaible INT(1),
product_audio_jack VARCHAR (255),
product_face_unlock INT(1),
product_safe_face_unlock INT(1)
);
`You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"INSERT INTO product_specifics (product_spec_url, product_name, product_price, p' at line 1`,
随意留下任何改进我的代码的建议; 提前致谢
我不认为roduct_processor_name
是表中的有效列。
(目前尚不清楚这是拼写错误还是复制/粘贴错误,或者这实际上是代码中的内容。)
另请注意,括在单引号中的'null'
是字符串文字; 如果我们想指定一个空值,我们使用NULL
关键字,而不是用单引号括起来。
(另外,为什么拼写avaible
?通常,使用实际的英语单词更容易,而不是特殊的缩写。)
重新格式化的 SQL 语句:
INSERT INTO product_specifics
( product_spec_url
, product_name
, product_price
, product_date
, product_water_resistan
, product_ip_rating
, product_battery_capacity
, product_fast_charging
, product_brand
, product_image_url
, product_screen_resolution
, product_screen_width
, product_pixel_per_inch
, product_processor
, roduct_processor_name /* invalid column name ? */
, product_ram
, product_storage
, product_storage_expandable
, product_rear_camera_resolution
, product_rear_camera_number
, product_front_camera_resolution
, product_front_camera_number
, product_operating_system_name
, product_operating_system_version
, product_wifi_standards
, product_bluetooth_avaible
, product_bluetooth_version
, product_nfc_avaible
, product_audio_jack
, product_face_unlock
, product_safe_face_unlock
)
VALUES
( 'https://gadgets.ndtv.com/acer-liquid-z6-plus-3730'
, 'Acer Liquid Z6 Plus'
, 'null' /* string literal, not NULL value */
, '2016-08-15'
, '0'
, 'null' /* string literal, not NULL value */
, '4080'
, 'null'
, 'Acer'
, 'https://drop.ndtv.com/TECH/product_database/images/831201661028PM_635_acer_liquid_z6_plus.jpeg?downsize=*:180&output-quality=80'
, '1920x1080 pixels'
, '5.5'
, '0'
, '1.3GHz octa-core'
, 'MediaTek MT6753'
, '3'
, '32'
, '1'
, '13'
, '1'
, '5'
, '1'
, 'Android'
, '6'
, '802.11 b/g/n'
, '1'
, 'null'
, '0'
, '3.5mm'
, '0'
, '0'
)
好吧,事实证明问题是我不必在`之前和之后放置“
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.