query_database
Executes SQL queries against a Bytebase database by auto-resolving the database name, with optional instance, project, schema, container, and row limit controls.
Instructions
Execute a SQL query against a Bytebase database. Resolves the database by name automatically.
Parameter | Required | Description |
database | Yes | Database name or substring (e.g., "employee_db" or "employee") |
statement | Yes | SQL query to execute |
instance | No | Workspace instance ID/name, or the full canonical name for a project instance |
project | No | Project name or ID to narrow resolution |
schema | No | Default schema for unqualified names (Postgres search path). An access grant applies only when this equals the grant's schema |
container | No | CosmosDB container (required for CosmosDB). An access grant applies only when this equals the grant's container |
limit | No | Max rows (default: 100, max: 1000) |
issueTitle | No | For a statement that may write: the issue's title if the user chooses Create an issue. The form shows it in that choice. Say what the change does, without data values. Without it, the form does not offer Create an issue |
Examples: query_database(database="employee_db", statement="SELECT * FROM users LIMIT 10") query_database(database="employee", instance="prod-pg", statement="SELECT count() FROM orders") query_database(database="employee", instance="projects/hr/instances/prod-pg", statement="SELECT count() FROM orders") query_database(database="employee_db", statement="UPDATE employee SET active = false WHERE id = 42", issueTitle="Deactivate an employee")
Notes:
Show the user the statement each answer came from, so they can check it read what they asked about.
When the user asks for an issue or a review of a change, call propose_database_change instead. It takes no schema, so when the request named one, qualify each name with it.
Masked data: masking replaces a value fully (by default ""), partly (e.g. "rn"), or with a hash. maskedColumns in the result names each masked column and why (not reported for MongoDB, CosmosDB or Elasticsearch). A masked value is a placeholder, not a value anything holds, so never write it back and never filter on it. Any statement containing "" is refused. When showing a partly masked value, wrap it in backticks: "rn" renders as bold Markdown.
Seeing masked values: the user can ask a project owner for a masking exemption, or, if the project allows just-in-time access, request an access grant with Unmask for this exact statement, schema and container. In a Read-write session, file the request with request_access_grant; otherwise the user requests it in the SQL Editor. Once it is approved, find the grant among the user's access grants, then rerun the granted statement unchanged with the grant's schema and container. appliedAccessGrant in the result names the grant that applied.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"database": "<database>",
"statement": "<statement>"
},
"name": "query_database"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| schema | No | ||
| project | No | ||
| database | Yes | ||
| instance | No | ||
| container | No | ||
| statement | Yes | ||
| issueTitle | No |