Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mysql = require('mysql');
- var config = require('./config.json');
- exports.handler = function(event, context, callback) {
- var pool = mysql.createPool({
- host : config.dbhost,
- user : config.dbuser,
- password : config.dbpassword,
- database : config.dbname,
- queueLimit : 0, // unlimited queueing
- connectionLimit : 10,
- multipleStatements : true,
- connectTimeout : 60 * 60 * 1000,
- acquireTimeout : 60 * 60 * 1000,
- timeout : 60 * 60 * 1000,
- });
- // console.log(pool)
- pool.getConnection(function(err, connection) {
- context.callbackWaitsForEmptyEventLoop = false;
- if (err) { console.log('===============>', err) }
- // Use the connection
- connection.query('SELECT * from Table', function (error, results, fields) {
- // And done with the connection.
- connection.release();
- // Handle error after the release.
- if (error) throw error;
- else console.log(results);
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement