我需要将数据从一个 json 文件加载到名为 Locality 的 MySQL 数据库表中。下面的代码返回一个 MySQL 语法错误。适用于 Aurora MySQL Serverless 的 MySQL 版本 5.7.30。我正在使用 aws-sdk,导入所有库,创建 RDS 实例。但出于某种原因,它返回 SQL 语法错误。如果我能看到 rds.batchExecuteStatement 生成的 SQL 内容,它也会有所帮助。我已经试过了,但没能找到 SQL 语句是什么。(帮助?)const loadLocalities = () => { // Read data from the json file const data = require('./GeoDyDB.json') // Extract the data from the JSON into a format RDSDataService.batchExecuteStatement expects for the parameterSets argument const localityParameterSets = data.map(function(location){ return [ {name: 'code', value: {stringValue: generate_locality_sort_key(location)}}, {name: 'synonyms', value: {stringValue: location.formatted_address}}, {name: 'country', value: {stringValue: location.Country}}, {name: 'state', value: {stringValue: location.State}}, {name: 'city', value: {stringValue: location.City}}, {name: 'zone', value: {stringValue: location.Zone}}, {name: 'ward', value: {stringValue: location.Ward}}, {name: 'colony', value: {stringValue: location.Colony}}, {name: 'pincode', value: {isNull: true}}, {name: 'lat', value: {stringValue: location.Lat.toString()}}, {name: 'lng', value: {stringValue: location.Lng.toString()}}, {name: 'geohash', value: {stringValue: location.Country}}, {name: 'obj', value: {stringValue: location.Country}} /* more columns */ ] }) // Create the SQL statement to run for all the items to insert as per AWS Docs linked above sqlStatement = `INSERT INTO Locality (code, synonyms, country, state, city, zone, ward, colony, pincode, lat, lng, geohash, obj) VALUES (:code, :synonyms, :country, :state, :city, :zone, :ward, :colony, :pincode, :lat, :lng, :geohash, :obj);` };}
添加回答
举报
0/150
提交
取消