This commit is contained in:
Benjamin Toby 2023-09-21 15:00:04 +01:00
parent 70ee0a2c0a
commit 44b013147e
77 changed files with 8511 additions and 8495 deletions

View File

@ -28,7 +28,9 @@ const connection = mysql.createConnection({
database: process.env.DSQL_DB_NAME,
password: process.env.DSQL_PASS,
charset: "utf8mb4",
port: process.env.DSQL_PORT?.match(/.../) ? parseInt(process.env.DSQL_PORT) : undefined,
port: process.env.DSQL_PORT?.match(/.../)
? parseInt(process.env.DSQL_PORT)
: undefined,
timeout: 5000,
});
@ -52,7 +54,13 @@ const connection = mysql.createConnection({
*
* @returns {Promise<*>}
*/
module.exports = async function dbHandler({ query, values, database, dbSchema, tableName }) {
module.exports = async function dbHandler({
query,
values,
database,
dbSchema,
tableName,
}) {
/**
* Declare variables
*
@ -60,10 +68,15 @@ module.exports = async function dbHandler({ query, values, database, dbSchema, t
*/
let changeDbError;
console.log(connection.config);
if (database) {
connection.changeUser({ database: database }, (error) => {
if (error) {
console.log("DB handler error in switching database:", error.message);
console.log(
"DB handler error in switching database:",
error.message
);
changeDbError = error.message;
}
});
@ -90,7 +103,10 @@ module.exports = async function dbHandler({ query, values, database, dbSchema, t
if (values?.[0]) {
connection.query(query, values, (error, results, fields) => {
if (error) {
console.log("DB handler error with values array:", error.message);
console.log(
"DB handler error with values array:",
error.message
);
console.log("SQL:", error.sql);
console.log("State:", error.sqlState, error.sqlMessage);

View File

@ -1,6 +1,6 @@
{
"name": "datasquirel",
"version": "1.9.0",
"version": "1.9.2",
"description": "Cloud-based SQL data management tool",
"main": "index.js",
"bin": {