dsql-admin/dsql-app/package-shared/shell/checkDb.ts

31 lines
836 B
TypeScript
Raw Normal View History

2025-01-13 08:00:21 +00:00
require("dotenv").config({ path: "./../.env" });
import mysql from "serverless-mysql";
2025-01-14 15:27:08 +00:00
import grabDSQLConnection from "../utils/grab-dsql-connection";
2025-01-13 08:00:21 +00:00
/**
* # 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 () => {
2025-01-14 15:27:08 +00:00
const CONNECTION = grabDSQLConnection();
2025-01-13 08:00:21 +00:00
try {
2025-01-14 15:27:08 +00:00
const result = await CONNECTION.query(
2025-01-13 08:00:21 +00:00
"SELECT id,first_name,last_name FROM users LIMIT 3"
);
console.log("Connection Query Success =>", result);
} catch (error: any) {
console.log("Connection query ERROR =>", error.message);
} finally {
2025-01-14 15:27:08 +00:00
CONNECTION?.end();
2025-01-13 08:00:21 +00:00
process.exit();
}
})();