Created
November 28, 2021 14:40
-
-
Save mshakhomirov/31dba2bf1b260cf13e8d22afb21d21e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mysql = require('mysql2/promise'); | |
const config = require('./config.json'); | |
exports.handler = async (event, context) => { | |
try { | |
let data = await processEvent(event, tables); | |
context.succeed(data); | |
} catch (e) { | |
console.log(e); | |
context.done(e); | |
} | |
}; | |
let processEvent = async (event, tables) => { | |
// This will create a connection to your database: | |
let pool = mysql.createPool({ | |
host: config.rds_host, | |
user: config.name, | |
password: config.password, | |
waitForConnections: true, | |
connectionLimit:10, | |
queueLimit:0, | |
timezone: '+00:00' | |
}); | |
const result = await getResult(sql, pool); | |
return {'Query result': `${result}`} | |
} | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment