|
| 1 | +--- |
| 2 | +title: "singlestore-sql" |
| 3 | +type: docs |
| 4 | +weight: 1 |
| 5 | +description: > |
| 6 | + A "singlestore-sql" tool executes a pre-defined SQL statement against a SingleStore |
| 7 | + database. |
| 8 | +aliases: |
| 9 | +- /resources/tools/singlestore-sql |
| 10 | +--- |
| 11 | + |
| 12 | +## About |
| 13 | + |
| 14 | +A `singlestore-execute-sql` tool executes a SQL statement against a SingleStore |
| 15 | +database. It's compatible with the following sources: |
| 16 | + |
| 17 | +- [singlestore](../../sources/singlestore.md) |
| 18 | + |
| 19 | +The specified SQL statement expects parameters in the SQL query to be in the form of placeholders `?`. |
| 20 | + |
| 21 | +## Example |
| 22 | + |
| 23 | +> **Note:** This tool uses parameterized queries to prevent SQL injections. |
| 24 | +> Query parameters can be used as substitutes for arbitrary expressions. |
| 25 | +> Parameters cannot be used as substitutes for identifiers, column names, table |
| 26 | +> names, or other parts of the query. |
| 27 | +
|
| 28 | +```yaml |
| 29 | +tools: |
| 30 | + search_flights_by_number: |
| 31 | + kind: singlestore-sql |
| 32 | + source: my-s2-instance |
| 33 | + statement: | |
| 34 | + SELECT * FROM flights |
| 35 | + WHERE airline = ? |
| 36 | + AND flight_number = ? |
| 37 | + LIMIT 10 |
| 38 | + description: | |
| 39 | + Use this tool to get information for a specific flight. |
| 40 | + Takes an airline code and flight number and returns info on the flight. |
| 41 | + Do NOT use this tool with a flight id. Do NOT guess an airline code or flight number. |
| 42 | + A airline code is a code for an airline service consisting of two-character |
| 43 | + airline designator and followed by flight number, which is 1 to 4 digit number. |
| 44 | + For example, if given CY 0123, the airline is "CY", and flight_number is "123". |
| 45 | + Another example for this is DL 1234, the airline is "DL", and flight_number is "1234". |
| 46 | + If the tool returns more than one option choose the date closes to today. |
| 47 | + Example: |
| 48 | + {{ |
| 49 | + "airline": "CY", |
| 50 | + "flight_number": "888", |
| 51 | + }} |
| 52 | + Example: |
| 53 | + {{ |
| 54 | + "airline": "DL", |
| 55 | + "flight_number": "1234", |
| 56 | + }} |
| 57 | + parameters: |
| 58 | + - name: airline |
| 59 | + type: string |
| 60 | + description: Airline unique 2 letter identifier |
| 61 | + - name: flight_number |
| 62 | + type: string |
| 63 | + description: 1 to 4 digit number |
| 64 | +``` |
| 65 | +
|
| 66 | +### Example with Template Parameters |
| 67 | +
|
| 68 | +> **Note:** This tool allows direct modifications to the SQL statement, |
| 69 | +> including identifiers, column names, and table names. **This makes it more |
| 70 | +> vulnerable to SQL injections**. Using basic parameters only (see above) is |
| 71 | +> recommended for performance and safety reasons. For more details, please check |
| 72 | +> [templateParameters](..#template-parameters). |
| 73 | +
|
| 74 | +```yaml |
| 75 | +tools: |
| 76 | + list_table: |
| 77 | + kind: singlestore-sql |
| 78 | + source: my-s2-instance |
| 79 | + statement: | |
| 80 | + SELECT * FROM {{.tableName}}; |
| 81 | + description: | |
| 82 | + Use this tool to list all information from a specific table. |
| 83 | + Example: |
| 84 | + {{ |
| 85 | + "tableName": "flights", |
| 86 | + }} |
| 87 | + templateParameters: |
| 88 | + - name: tableName |
| 89 | + type: string |
| 90 | + description: Table to select from |
| 91 | +``` |
| 92 | +
|
| 93 | +## Reference |
| 94 | +
|
| 95 | +| **field** | **type** | **required** | **description** | |
| 96 | +|--------------------|:------------------------------------------------:|:------------:|--------------------------------------------------------------------------------------------------------------------------------------------| |
| 97 | +| kind | string | true | Must be "singlestore-sql". | |
| 98 | +| source | string | true | Name of the source the SQL should execute on. | |
| 99 | +| description | string | true | Description of the tool that is passed to the LLM. | |
| 100 | +| statement | string | true | SQL statement to execute on. | |
| 101 | +| parameters | [parameters](../#specifying-parameters) | false | List of [parameters](../#specifying-parameters) that will be inserted into the SQL statement. | |
| 102 | +| templateParameters | [templateParameters](..#template-parameters) | false | List of [templateParameters](..#template-parameters) that will be inserted into the SQL statement before executing prepared statement. | |
0 commit comments