Skip to content

Instantly share code, notes, and snippets.

@mshakhomirov
Created November 28, 2021 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mshakhomirov/31dba2bf1b260cf13e8d22afb21d21e9 to your computer and use it in GitHub Desktop.
Save mshakhomirov/31dba2bf1b260cf13e8d22afb21d21e9 to your computer and use it in GitHub Desktop.
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