modbus-logger/utils/database.util.js
2023-10-23 23:52:12 +03:00

16 lines
350 B
JavaScript

import fs from "fs/promises";
import db from "#root/config/database.config.js";
/**
* Reads the `.sql` file and executes the query
* @param {string} filepath
*/
export async function runQueryFromFile(filepath) {
try {
const query = await fs.readFile(filepath);
await db.run(query.toString());
} catch (error) {
throw error;
}
}