我需要將數據從一個 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);`? ? };}
MySQL Serverless RDSDataService.batchExecute
尚方寶劍之說
2023-05-19 17:43:29