mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
653 B
25 lines
653 B
2 years ago
|
const mysql = require("mysql2");
|
||
|
|
||
|
const mysqlExec = async (query) => {
|
||
|
// creates a new mysql connection using credentials from cypress.json env's
|
||
|
const connection = mysql.createConnection({
|
||
|
"host": "127.0.0.1",
|
||
|
"user": "root",
|
||
|
"password": "password"
|
||
|
});
|
||
|
// start connection to db
|
||
|
connection.connect();
|
||
|
// exec query + disconnect to db as a Promise
|
||
|
return new Promise((resolve, reject) => {
|
||
|
connection.query(query, (error, results) => {
|
||
|
if (error) reject(error);
|
||
|
else {
|
||
|
connection.end();
|
||
|
// console.log(results)
|
||
|
return resolve(results);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
|
||
|
export default mysqlExec;
|