Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. const mysql = require('mysql');
  2.  
  3. var config = require('./config.json');
  4.  
  5. exports.handler = function(event, context, callback) {
  6.  
  7. var pool = mysql.createPool({
  8. host : config.dbhost,
  9. user : config.dbuser,
  10. password : config.dbpassword,
  11. database : config.dbname,
  12. queueLimit : 0, // unlimited queueing
  13. connectionLimit : 10,
  14. multipleStatements : true,
  15. connectTimeout : 60 * 60 * 1000,
  16. acquireTimeout : 60 * 60 * 1000,
  17. timeout : 60 * 60 * 1000,
  18. });
  19.  
  20. // console.log(pool)
  21.  
  22. pool.getConnection(function(err, connection) {
  23.  
  24. context.callbackWaitsForEmptyEventLoop = false;
  25.  
  26. if (err) { console.log('===============>', err) }
  27. // Use the connection
  28. connection.query('SELECT * from Table', function (error, results, fields) {
  29. // And done with the connection.
  30. connection.release();
  31. // Handle error after the release.
  32. if (error) throw error;
  33. else console.log(results);
  34. });
  35.  
  36. });
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement