Analyzes SQL query logs and triggers a warning if a specified condition is missing from the query.
This app will run an analysis on the log of the sql execution, go to mysql database settings and enable logging to the general_log table.
SET GLOBAL general_log = 'ON';
SET GLOBAL log_output='TABLE';
SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 0;
To set up database
- rename
config.sample.yaml
toconfig.yaml
- modify the yaml settings
https://github.com/tkc/sql-dog/blob/master/config.sample.yaml
To set up validation
- rename
linter.sample.yaml
tolinter.yaml
- modify the yaml settings
https://github.com/tkc/sql-dog/blob/master/linter.sample.yaml
run query analyzer and show report.
$ go run ./cmd/lint/main.go
clear general_log table records.
$ go run ./cmd/clean/main.go
- Check if a specific where condition set for a query to the target table.
- Check if NOT NUll constraint attached to the target table.
- read other format query log. ex / http request, text log and other.
Parsing the sql query and annotating it for parsing
Compares the results of the analysis of the query with user-defined validations and outputs an analysis report.