Guest User

Untitled

a guest
Feb 7th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. var mysql = require('mysql');
  2.  
  3. var pool = mysql.createPool({
  4. connectionLimit: 5,
  5. host: 'localhost',
  6. user: 'root',
  7. password: '',
  8. database: 'todoapp'
  9. });
  10.  
  11. pool.getConnection(function (err, connection) {
  12. if(err){
  13. console.log("error connecting: " + err.message);
  14. return;
  15. }
  16. console.log(connection);
  17. // Use the connection
  18. connection.query('SELECT * FROM myguests', function (err, rows) {
  19. if (err) console.log("error query: " + err.message);
  20. console.log(rows)
  21. // And done with the connection.
  22. connection.release();
  23.  
  24. // Don't use the connection here, it has been returned to the pool.
  25. });
  26. });
Add Comment
Please, Sign In to add comment