mysql-query-validator
Version:
This is just a simple wrapper over [this Golang executable](https://github.com/xwb1989/sqlparser) to validate SQL queries.
21 lines • 816 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
const shell_escape_1 = __importDefault(require("shell-escape"));
const path_1 = __importDefault(require("path"));
const BINARY = path_1.default.join(__dirname, '../dist/sqlvalidator');
function validate(query) {
const args = [`${BINARY}-${process.platform}`, '--query', query, 'validate'];
const output = child_process_1.execSync(shell_escape_1.default(args))
.toString()
.trim();
if (output === 'valid') {
return;
}
throw new Error(output);
}
exports.validate = validate;
//# sourceMappingURL=index.js.map