dsql-admin/dsql-app/package-shared/shell/test-external-server.ts
Benjamin Toby 81cf010cb5 Updates
2025-01-14 16:27:08 +01:00

36 lines
927 B
TypeScript
Executable File

require("dotenv").config({ path: "./.env" });
import grabDSQLConnection from "../utils/grab-dsql-connection";
/**
* # Main DB Handler Function
* @async
*
* @param {object} params
* @param {string} params.query
* @param {string[] | object} [params.values]
* @param {string} [params.database]
*
* @returns {Promise<object|null>}
*/
(async () => {
const CONNECTION = grabDSQLConnection({ noDb: true });
/**
* Switch Database
*
* @description If a database is provided, switch to it
*/
try {
const result = await CONNECTION.query("SHOW DATABASES");
const parsedResults = JSON.parse(JSON.stringify(result));
console.log("parsedResults =>", parsedResults);
} catch (error: any) {
console.log("Connection query ERROR =>", error.message);
} finally {
CONNECTION?.end();
process.exit();
}
})();