Guest User

Untitled

a guest
Feb 18th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. const conn = mysql.createConnection({
  2. host: 'localhost',
  3. port: 3306,
  4. username: root,
  5. password: '',
  6. multipleStatements: true,
  7. timeout: 5000
  8. });
  9.  
  10. conn.connect((err) => {
  11. if (err) {
  12. // console.log(err.code);
  13. // console.log(err.fatal);
  14. // console.log(err.sql);
  15. // console.log(err.sqlState);
  16. // console.log(err.sqlMessage);
  17.  
  18. dialog.showErrorBox('Uh-Oh!', err.code);
  19.  
  20. return;
  21. }
  22.  
  23. const SQL = 'SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = "' + db + '"';
  24.  
  25. conn.query(SQL, function (err, rows, fields) {
  26. if (err) {
  27. dialog.showErrorBox('Uh-Oh!', err.code);
  28.  
  29. return;
  30. }
  31.  
  32. console.log(SQL);
  33. console.log(rows); // []
  34. console.log(fields);
  35. });
  36. });
  37.  
  38. SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = "survive"
Add Comment
Please, Sign In to add comment