daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const faker = require('faker')
  2. const mysql = require('mysql2/promise')
  3.  
  4.  
  5. // function createRow () {
  6. //   return {
  7. //     column: faker.database.column(),
  8. //     type: faker.database.type(),
  9. //     collation: faker.database.collation(),
  10. //     engine: faker.database.engine()
  11. //   }
  12. // }
  13.  
  14. async function main () {
  15. // create the connection to database
  16.   const connection = await mysql.createConnection({
  17.     host: '',
  18.     user: '',
  19.     database: '',
  20.     password: ''
  21.   })
  22.  
  23.   // const ok = await connection.query('UPDATE `test` SET field = ? WHERE id >= ?', ['hello', 1000])
  24.   // const ok = await connection.query('DELETE FROM `test` WHERE id >= ?', [1000])
  25.   const ok = await connection.query('INSERT INTO `test` SET ?', { id: 1001, field: 'hello' })
  26.  
  27.   // const [ rows ] = await connection.execute('SELECT * FROM `test`')
  28.   return 'listening to port *:3000'
  29. }
  30.  
  31. main()
  32. .then(console.log)
  33. .catch(console.error)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top