Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tkc/sql-dog
Analyzes SQL query logs and triggers a warning if a specified condition is missing from the query.
https://github.com/tkc/sql-dog
analysis analyzer database go sql sql-parser
Last synced: about 1 month ago
JSON representation
Analyzes SQL query logs and triggers a warning if a specified condition is missing from the query.
- Host: GitHub
- URL: https://github.com/tkc/sql-dog
- Owner: tkc
- Created: 2020-10-03T12:36:55.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-28T11:04:10.000Z (4 months ago)
- Last Synced: 2024-08-28T12:27:03.286Z (4 months ago)
- Topics: analysis, analyzer, database, go, sql, sql-parser
- Language: Go
- Homepage:
- Size: 67.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Security: SECURITY.md
Awesome Lists containing this project
README
![sql-dog](https://github.com/tkc/sql-dog/workflows/sql-dog/badge.svg?branch=master)
![reviewdog](https://github.com/tkc/sql-dog/workflows/reviewdog/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/tkc/sql-dog)](https://goreportcard.com/report/github.com/tkc/sql-dog)# sql-dog
Analyzes SQL query logs and triggers a warning if a specified condition is missing from the query.## MySQL Table Setting
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.
```sql
SET GLOBAL general_log = 'ON';
SET GLOBAL log_output='TABLE';SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 0;
```## Database Setting
To set up database
- rename `config.sample.yaml` to `config.yaml`
- modify the yaml settingshttps://github.com/tkc/sql-dog/blob/master/config.sample.yaml
## Validate Setting
To set up validation
- rename `linter.sample.yaml` to `linter.yaml`
- modify the yaml settingshttps://github.com/tkc/sql-dog/blob/master/linter.sample.yaml
## Run
run query analyzer and show report.
```bash
$ go run ./cmd/lint/main.go
```clear general_log table records.
```bash
$ go run ./cmd/clean/main.go
```### Features
- Check if a specific where condition set for a query to the target table.
- Check if NOT NUll constraint attached to the target table.## Todo
- [ ] read other format query log. ex / http request, text log and other.
## Architecture
### Analyzer
Parsing the sql query and annotating it for parsing### Validator
Compares the results of the analysis of the query with user-defined validations and outputs an analysis report.