简体   繁体   English

无缘无故出现错误 2064

[英]getting error 2064 for no apparent reason

Ok so I am uploading values to a mysql table from nodejs and I get error 1064 as if Its badly formattedg but I can't find the issue.好的,所以我正在将值从 nodejs 上传到 mysql 表,但我收到错误 1064,就好像它的格式错误一样,但我找不到问题。 This is the query:这是查询:

`"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');"`

This is the code这是代码

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 is an argument that comes from another module, it is a huge array of big object, It's here: https://pastebin.com/VFEWNuXx ; potusParse 是一个来自另一个模块的参数,它是一个巨大的对象数组,它在这里: https : //pastebin.com/VFEWNuXx This is the query that creates the table:这是创建表的查询:

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`,

Feel free to leave any suggestion for improving my code in general;随意留下任何改进我的代码的建议; thanks in advance提前致谢

I don't think roduct_processor_name is a valid column in the table.我不认为roduct_processor_name是表中的有效列。

(It's not clear if that's a typo or copy/paste error, or if that's actually what is in the code.) (目前尚不清楚这是拼写错误还是复制/粘贴错误,或者这实际上是代码中的内容。)

Also note that enclosed in single quotes, 'null' is a string literal;另请注意,括在单引号中的'null'是字符串文字; if we want to specify a null value, we use the NULL keyword, not enclosed in single quotes.如果我们想指定一个空值,我们使用NULL关键字,而不是用单引号括起来。

(Also, why the spelling avaible ? Typically, it's easier to use actual english words, and not peculiar abbreviations.) (另外,为什么拼写avaible ?通常,使用实际的英语单词更容易,而不是特殊的缩写。)


Reformatted SQL statement:重新格式化的 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM