@segment/mysql-query-validator
Version:
This is just a simple wrapper over [this Golang executable](https://github.com/xwb1989/sqlparser) to validate SQL queries.
31 lines (24 loc) • 588 B
Markdown
# mysql-query-validator
This is just a simple wrapper over [this Golang executable](https://github.com/xwb1989/sqlparser) to validate SQL queries.
## Installation
```bash
yarn add mysql-query-validator
```
## Example
```js
import { validate } from 'mysql-query-validator'
try {
validate(`
create table test (
id varchar(20) not null,
created_at datetime(6),
slug varbinary(255),
enabled tinyint(1),
labels json // missing comma
url blob
)
`)
} catch (err) {
console.error(err.message) // syntax error at position N near 'url'
}
```