oceanbase-sql

An “oceanbase-sql” tool executes a pre-defined SQL statement against an OceanBase database.

About

An oceanbase-sql tool executes a pre-defined SQL statement against an OceanBase database. It’s compatible with the following source:

The specified SQL statement is executed as a prepared statement, and expects parameters in the SQL query to be in the form of placeholders ?.

Example

Note: This tool uses parameterized queries to prevent SQL injections. Query parameters can be used as substitutes for arbitrary expressions. Parameters cannot be used as substitutes for identifiers, column names, table names, or other parts of the query.

tools:
  search_flights_by_number:
    kind: oceanbase-sql
    source: my-oceanbase-instance
    statement: |
      SELECT * FROM flights
      WHERE airline = ?
      AND flight_number = ?
      LIMIT 10
    description: |
      Use this tool to get information for a specific flight.
      Takes an airline code and flight number and returns info on the flight.
      Do NOT use this tool with a flight id. Do NOT guess an airline code or flight number.
      Example:
      {{
          "airline": "CY",
          "flight_number": "888",
      }}
    parameters:
      - name: airline
        type: string
        description: Airline unique 2 letter identifier
      - name: flight_number
        type: string
        description: 1 to 4 digit number

Example with Template Parameters

Note: This tool allows direct modifications to the SQL statement, including identifiers, column names, and table names. This makes it more vulnerable to SQL injections. Using basic parameters only (see above) is recommended for performance and safety reasons.

tools:
  list_table:
    kind: oceanbase-sql
    source: my-oceanbase-instance
    statement: |
      SELECT * FROM {{.tableName}};
    description: |
      Use this tool to list all information from a specific table.
      Example:
      {{
          "tableName": "flights",
      }}
    templateParameters:
      - name: tableName
        type: string
        description: Table to select from

Example with Array Parameters

tools:
  search_flights_by_ids:
    kind: oceanbase-sql
    source: my-oceanbase-instance
    statement: |
      SELECT * FROM flights
      WHERE id IN (?)
      AND status IN (?)
    description: |
      Use this tool to get information for multiple flights by their IDs and statuses.
      Example:
      {{
          "flight_ids": [1, 2, 3],
          "statuses": ["active", "scheduled"]
      }}
    parameters:
      - name: flight_ids
        type: array
        description: List of flight IDs to search for
        items:
          name: flight_id
          type: integer
          description: Individual flight ID
      - name: statuses
        type: array
        description: List of flight statuses to filter by
        items:
          name: status
          type: string
          description: Individual flight status

Reference

fieldtyperequireddescription
kindstringtrueMust be “oceanbase-sql”.
sourcestringtrueName of the source the SQL should execute on.
descriptionstringtrueDescription of the tool that is passed to the LLM.
statementstringtrueSQL statement to execute on.
parametersparametersfalseList of parameters that will be inserted into the SQL statement.
templateParameterstemplateParametersfalseList of templateParameters that will be inserted into the SQL statement before executing prepared statement.