An intelligent MySQL linter and checker
Last updated 3 months ago by joereynolds .
MIT · Original npm · Tarball · package.json
$ cnpm install sql-lint 
SYNC missed versions from official npm registry.


sql-lint is a linter for MySQL, it brings back any error from the MySQL server as well as custom errors written for sql-lint.

An example of some of the checks performed

  • DELETE statements missing WHERE clauses
  • Databases not found
  • Tables not found
  • Weird characters in a query where they shouldn't be

Any others!

To run

Run ./build.sh, after that, you will have sql-lint installed locally. This is a workaround until a package is made.

Linting a query

sql-lint works on queries with the --query flag.

> sql-lint --query="DELETE FROM test;"
query:1 Delete missing WHERE, intentional?

Linting a file

sql-lint works on files with the --file flag.

> sql-lint --file="test/test.sql" 
test/test.sql:13 Bad code point
test/test.sql:40 Delete missing WHERE, intentional?
test/test.sql:6 Database 'test' does not exist.
test/test.sql:10 Database 'dykes_reservations' does not exist.
test/test.sql:11 Database 'dykes_res' does not exist.
test/test.sql:13 [ER_PARSE_ERROR] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRO�' at line 1
test/test.sql:16 [ER_NO_DB_ERROR] No database selected
test/test.sql:29 [ER_NO_DB_ERROR] No database selected
test/test.sql:54 [ER_NO_SUCH_TABLE] Table 'symfony.dont_exist' doesn't exist

Linting stdin

sql-lint works with stdin if you don't supply any arguments.

> echo "DELETE FROM test;" | sql-lint
stdin:1 Delete missing WHERE, intentional?

Editor integration

There is a patch here which will allow sql-lint to work with ALE for Vim and Neovim.


Configuring sql-lint with connection details allows errors from the server to come through. You'll probably want these as they supply even more information about what's going wrong.

You can connect in two ways:


You can connect via the command line if you wish with the respective flags.

sql-lint --host="localhost" --user="root" --password="hunter2" --query="SELECT 1;"

Via config.json

A configuration file for sql-lint can reside in ~/.config/sql-lint/config.json

You should put the following in there for more intelligent errors to come through

    "host": "localhost",
    "user": "root",
    "password": "hunter2"


To test

./build.sh //This will run more than just the tests (recommended)

Integration tests

Integration tests are not (currently) ran on travis. run ./tests.sh to run the tests.

Current Tags

  • 0.0.6                                ...           latest (3 months ago)

4 Versions

  • 0.0.6                                ...           3 months ago
  • 0.0.4                                ...           3 months ago
  • 0.0.3                                ...           3 months ago
  • 0.0.2                                ...           3 months ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (11)
Dev Dependencies (2)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |