SQL Advisor API
The SQL Advise API provides SQL checks based on your schema review policy.
Endpoint
GET
http://localhost:8080/v1/sql/advise
Query parameters
Parameter | Required? | Description | Example |
---|---|---|---|
environment | Required | The environment name for your schema review policy. Case sensitive | Dev |
statement | Required | The SQL statement. | SELECT * FROM `table` |
host | Optional | The instance host. Available values: MySQL , PostgreSQL , TiDB . | 127.0.0.1 |
port | Optional | The instance port. Available values: MySQL , PostgreSQL , TiDB . | 3306 |
databaseName | Optional | The database name in the instance. | DB Name |
databaseType | Optional | The database type. Required if port , host , and databaseName are not specified. Available values: MySQL , PostgreSQL , TiDB . | MySQL |
Once you have created the schema review policy in the Bytebase UX, you can call the SQL Advise API with environment
, statement
, and databaseType
parameters. This will conduct the SQL check against statements without database catalog information.
You can also create the instance and database in the UX, then call the API with environment
, statement
, host
, port
, and databaseName
parameters. This will allow the API to retrieve the database catalog information and assist the SQL check.
Response body
code
: The error code. Check error code for advisor for details.content
: The error message.status
: The SQL check status, should beSUCCESS
,WARN
orERROR
.title
: The schema review rule type. See the list of supported rules.
Response codes
Code | Description |
---|---|
200 | OK |
400 | One of the provided values in the request query is invalid. |
500 | Internal server error |
Example
Request
Response
Request
Response