Advertisement
Guest User

Untitled

a guest
Feb 18th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. var connection = mysql.createConnection({
  2. host : "localhost",
  3. user : "root",
  4. password: ""
  5. });
  6.  
  7. connection.connect();
  8. connection.query("use northwind");
  9.  
  10. extends layout
  11.  
  12. block content
  13. h1= title
  14. p Welcome to #{title}
  15. table
  16. tr
  17. th CustomerID
  18. th Company
  19. each(item in items)
  20. tr
  21. td=item.id
  22. td=item.company
  23.  
  24. var express = require('express');
  25. var router = express.Router();
  26. var mysql = require('mysql');
  27.  
  28. var connection = mysql.createConnection({
  29. host : "localhost",
  30. user : "root",
  31. database: 'northwind',
  32. password: ""
  33. });
  34.  
  35. /* GET home page.
  36. router.get('/', function(req, res, next) {
  37. res.render('index', { title: 'Express' });
  38. });*/
  39.  
  40. /* GET home page. */
  41. router.get('/', function(req, res) {
  42. /* exports.index = function(req, res) {
  43. var connection = mysql.createConnection(conn);
  44. var query ='SELECT * FROM customers';
  45. connection.query(query, function(err, rows, fields) {
  46. if(err) throw err;
  47. res.render('index', { title: 'North Wind BB', 'items': rows });
  48. });
  49. }; */
  50. var connection = mysql.createConnection(connection);
  51. var query ='SELECT * FROM customers';
  52. connection.query(query, function(err, rows, fields)
  53. {
  54. if (err)
  55. {
  56. console.log(err);
  57. }
  58. else{
  59. res.render('index', { title: 'North Wind BB', 'items': rows });
  60. console.log(rows);
  61. }
  62.  
  63. });
  64.  
  65. });
  66. module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement