const fs = require(`fs`);
const mysql = require(`./index`);

(async() => {
 const database = `foobar`;
 
  const con = await mysql.createConnection(JSON.parse(fs.readFileSync(`mysql-config.json`)));

  //not working bottom
  con.on("error", (err) => {
    console.log(`HERE`);
    console.log(err);
  });

  try {
    await con.awaitQuery('USE name_of_db_that_does_not_exist');
  } catch ( err ) {
    console.log(err);
  }
  
//  const sql = "CREATE DATABASE " + database;
//
//  const result = await con.awaitQuery(sql);
//
//  console.log(result); //ERROR! DATABASE NOT FOUND
  
  con.end();
})();
