mirror of
https://github.com/sergeyyarkov/modbus-logger.git
synced 2026-10-11 02:18:51 +03:00
16 lines
350 B
JavaScript
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;
|
|
}
|
|
}
|