Skip to content

Commit

Permalink
Merge branch 'main' into mysql-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuan325 authored Jan 29, 2025
2 parents 3db06e9 + b0ecc16 commit 90fbeba
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 37 deletions.
62 changes: 42 additions & 20 deletions docs/en/resources/sources/cloud-sql-mssql.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Cloud SQL for SQL Server Source
---
title: "Cloud SQL for SQL Server"
linkTitle: "Cloud SQL (SQL Server)"
type: docs
weight: 1
description: >
Cloud SQL for SQL Server is a fully-managed database service for SQL Server.
---

## About

[Cloud SQL for SQL Server][csql-mssql-docs] is a managed database service that
helps you set up, maintain, manage, and administer your SQL Server databases on
Expand All @@ -12,30 +21,43 @@ to a database by following these instructions][csql-mssql-connect].

## Requirements

### IAM Identity
### IAM Permissions

By default, this source uses the [Cloud SQL Go Connector][csql-go-conn] to
authorize and establish mTLS connections to your Cloud SQL instance. The Go
connector uses your [Application Default Credentials (ADC)][adc] to authorize
your connection to Cloud SQL.

In addition to [setting the ADC for your server][set-adc], you need to ensure the
IAM identity has been given the following IAM roles:
In addition to [setting the ADC for your server][set-adc], you need to ensure
the IAM identity has been given the following IAM roles (or corresponding
permissions):

- `roles/cloudsql.client`

> **_NOTE:_**
> If you are connecting from Compute Engine, make sure your VM also has the
> [proper scope][gce-access-scopes] to connect using the Cloud SQL Admin API.
[csql-go-conn]: https://github.com/GoogleCloudPlatform/cloud-sql-go-connector
[adc]: https://cloud.google.com/docs/authentication#adc
[set-adc]: https://cloud.google.com/docs/authentication/provide-credentials-adc
[gce-access-scopes]: https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam

### Networking

### Network Path
Cloud SQL supports connecting over both from external networks via the internet
([public IP][public-ip]), and internal networks ([private IP][private-ip]).
For more information on choosing between the two options, see the Cloud SQL page
[Connection overview][conn-overview].

Currently, Cloud SQL for SQL Server supports connection over both [private IP][private-ip] and
[public IP][public-ip]. Set the `ipType` parameter in your source
configuration to `public` or `private`.
You can configure the `ipType` parameter in your source configuration to
`public` or `private` to match your cluster's configuration. Regardless of which
you choose, all connections use IAM-based authorization and are encrypted with
mTLS.

[private-ip]: https://cloud.google.com/sql/docs/sqlserver/configure-private-ip
[public-ip]: https://cloud.google.com/sql/docs/sqlserver/configure-ip
[conn-overview]: https://cloud.google.com/sql/docs/sqlserver/connect-overview

### Database User

Expand All @@ -55,19 +77,19 @@ sources:
instance: my-instance
database: my_db
ipAddress: localhost
ipType: public
# ipType: private
```

## Reference

| **field** | **type** | **required** | **description** |
|-----------|:--------:|:------------:|------------------------------------------------------------------------------|
| kind | string | true | Must be "cloud-sql-postgres". |
| project | string | true | Id of the GCP project that the cluster was created in (e.g. "my-project-id"). |
| region | string | true | Name of the GCP region that the cluster was created in (e.g. "us-central1"). |
| instance | string | true | Name of the Cloud SQL instance within the cluser (e.g. "my-instance"). |
| database | string | true | Name of the Cloud SQL database to connect to (e.g. "my_db"). |
| ipAddress | string | true | IP address of the Cloud SQL instance to connect to.|
| ipType | string | true | IP Type of the Cloud SQL instance, must be either `public` or `private`. Default: `public`. |
| user | string | true | Name of the Postgres user to connect as (e.g. "my-pg-user"). |
| password | string | true | Password of the Postgres user (e.g. "my-password").
| **field** | **type** | **required** | **description** |
|-----------|:--------:|:------------:|---------------------------------------------------------------------------------------------|
| kind | string | true | Must be "cloud-sql-mssql". |
| project | string | true | Id of the GCP project that the cluster was created in (e.g. "my-project-id"). |
| region | string | true | Name of the GCP region that the cluster was created in (e.g. "us-central1"). |
| instance | string | true | Name of the Cloud SQL instance within the cluser (e.g. "my-instance"). |
| database | string | true | Name of the Cloud SQL database to connect to (e.g. "my_db"). |
| ipAddress | string | true | IP address of the Cloud SQL instance to connect to. |
| user | string | true | Name of the SQL Server user to connect as (e.g. "my-pg-user"). |
| password | string | true | Password of the SQL Server user (e.g. "my-password"). |
| ipType | string | false | IP Type of the Cloud SQL instance, must be either `public` or `private`. Default: `public`. |
96 changes: 96 additions & 0 deletions docs/en/resources/sources/cloud-sql-mysql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
title: "Cloud SQL for MySQL"
linkTitle: "Cloud SQL (MySQL)"
type: docs
weight: 1
description: >
Cloud SQL for MySQL is a fully-managed database service for MySQL.
---

## About

[Cloud SQL for MySQL][csql-mysql-docs] is a fully-managed database service
that helps you set up, maintain, manage, and administer your MySQL
relational databases on Google Cloud Platform.

If you are new to Cloud SQL for MySQL, you can try [creating and connecting
to a database by following these instructions][csql-mysql-quickstart].

[csql-mysql-docs]: https://cloud.google.com/sql/docs/mysql
[csql-mysql-quickstart]: https://cloud.google.com/sql/docs/mysql/connect-instance-local-computer

## Requirements

### IAM Permissions

By default, this source uses the [Cloud SQL Go Connector][csql-go-conn] to
authorize and establish mTLS connections to your Cloud SQL instance. The Go
connector uses your [Application Default Credentials (ADC)][adc] to authorize
your connection to Cloud SQL.

In addition to [setting the ADC for your server][set-adc], you need to ensure
the IAM identity has been given the following IAM roles (or corresponding
permissions):

- `roles/cloudsql.client`

> **_NOTE:_**
> If you are connecting from Compute Engine, make sure your VM also has the
> [proper scope][gce-access-scopes] to connect using the Cloud SQL Admin API.
[csql-go-conn]: https://github.com/GoogleCloudPlatform/cloud-sql-go-connector
[adc]: https://cloud.google.com/docs/authentication#adc
[set-adc]: https://cloud.google.com/docs/authentication/provide-credentials-adc
[gce-access-scopes]: https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam

### Networking

Cloud SQL supports connecting over both from external networks via the internet
([public IP][public-ip]), and internal networks ([private IP][private-ip]).
For more information on choosing between the two options, see the Cloud SQL page
[Connection overview][conn-overview].

You can configure the `ipType` parameter in your source configuration to
`public` or `private` to match your cluster's configuration. Regardless of which
you choose, all connections use IAM-based authorization and are encrypted with
mTLS.

[private-ip]: https://cloud.google.com/sql/docs/mysql/configure-private-ip
[public-ip]: https://cloud.google.com/sql/docs/mysql/configure-ip
[conn-overview]: https://cloud.google.com/sql/docs/mysql/connect-overview

### Database User

Current, this source only uses standard authentication. You will need to [create
a MySQL user][cloud-sql-users] to login to the database with.

[cloud-sql-users]: https://cloud.google.com/sql/docs/mysql/create-manage-users

## Example

```yaml
sources:
my-cloud-sql-mysql-source:
kind: "cloud-sql-mysql"
project: "my-project-id"
region: "us-central1"
instance: "my-instance"
database: "my_db"
user: "my-user"
password: "my-password"
# ipType: "private"
```

## Reference

| **field** | **type** | **required** | **description** |
|-----------|:--------:|:------------:|---------------------------------------------------------------------------------------------|
| kind | string | true | Must be "cloud-sql-mysql". |
| project | string | true | Id of the GCP project that the cluster was created in (e.g. "my-project-id"). |
| region | string | true | Name of the GCP region that the cluster was created in (e.g. "us-central1"). |
| instance | string | true | Name of the Cloud SQL instance within the cluster (e.g. "my-instance"). |
| database | string | true | Name of the MySQL database to connect to (e.g. "my_db"). |
| user | string | true | Name of the MySQL user to connect as (e.g. "my-pg-user"). |
| password | string | true | Password of the MySQL user (e.g. "my-password"). |
| ipType | string | false | IP Type of the Cloud SQL instance; must be one of `public` or `private`. Default: `public`. |
14 changes: 7 additions & 7 deletions docs/en/resources/sources/cloud-sql-pg.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If you are new to Cloud SQL for PostgreSQL, you can try [creating and connecting
to a database by following these instructions][csql-pg-quickstart].

[csql-pg-docs]: https://cloud.google.com/sql/docs/postgres
[csql-pg-quickstart]: https://cloud.google.com/sql/docs/postgres/connect-instance-local-compaduter
[csql-pg-quickstart]: https://cloud.google.com/sql/docs/postgres/connect-instance-local-computer

## Requirements

Expand Down Expand Up @@ -46,19 +46,19 @@ permissions):

### Networking

AlloyDB supports connecting over both from external networks via the internet
Cloud SQL supports connecting over both from external networks via the internet
([public IP][public-ip]), and internal networks ([private IP][private-ip]).
For more information on choosing between the two options, see the AlloyDB page
For more information on choosing between the two options, see the Cloud SQL page
[Connection overview][conn-overview].

You can configure the `ipType` parameter in your source configuration to
`public` or `private` to match your cluster's configuration. Regardless of which
you choose, all connections use IAM-based authorization and are encrypted with
mTLS.

[private-ip]: https://cloud.google.com/alloydb/docs/private-ip
[public-ip]: https://cloud.google.com/alloydb/docs/connect-public-ip
[conn-overview]: https://cloud.google.com/alloydb/docs/connection-overview
[private-ip]: https://cloud.google.com/sql/docs/postgres/configure-private-ip
[public-ip]: https://cloud.google.com/sql/docs/postgres/configure-ip
[conn-overview]: https://cloud.google.com/sql/docs/postgres/connect-overview

### Database User

Expand All @@ -79,7 +79,7 @@ sources:
database: "my_db"
user: "my-user"
password: "my-password"
# ipType: "public"
# ipType: "private"
```

## Reference
Expand Down
16 changes: 8 additions & 8 deletions docs/tools/mssql.md → docs/tools/mssql-sql.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cloud SQL Mssql Tool

A "mssql" tool executes a pre-defined SQL statement against a Cloud SQL for SQL Server
A "mssql-sql" tool executes a pre-defined SQL statement against a Cloud SQL for SQL Server
database. It's compatible with any of the following sources:

- [cloud-sql-mssql](../sources/cloud-sql-mssql.md)
Expand All @@ -20,12 +20,12 @@ db.QueryContext(ctx, `select * from t where ID = @ID and Name = @p2;`, sql.Named
```yaml
tools:
search_flights_by_number:
kind: mssql
kind: mssql-sql
source: my-instance
statement: |
SELECT * FROM flights
WHERE airline = @airline
AND flight_number = @number
AND flight_number = @flight_number
LIMIT 10
description: |
Use this tool to get information for a specific flight.
Expand All @@ -50,7 +50,7 @@ tools:
- name: airline
type: string
description: Airline unique 2 letter identifier
- name: number
- name: flight_number
type: string
description: 1 to 4 digit number
```
Expand All @@ -59,8 +59,8 @@ tools:
| **field** | **type** | **required** | **description** |
|-------------|:--------------------------------------------:|:------------:|-----------------------------------------------------------------------------------------------------|
| kind | string | true | Must be "mssql". |
| source | string | true | Name of the source the T-SQL statement should execute on.|
| description | string | true | Description of the tool that is passed to the LLM|
| statement | string | true | SQL statement to execute. |
| kind | string | true | Must be "mssql-sql". |
| source | string | true | Name of the source the T-SQL statement should execute on. |
| description | string | true | Description of the tool that is passed to the LLM. |
| statement | string | true | SQL statement to execute. |
| parameters | [parameter](README.md#specifying-parameters) | true | List of [parameters](README.md#specifying-parameters) that will be inserted into the SQL statement. |
62 changes: 62 additions & 0 deletions docs/tools/mysql-sql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# MySQL Tool

A "mysql-sql" tool executes a pre-defined SQL statement against a mysql
database. It's compatible with any of the following sources:
- [cloud-sql-mysql](../sources/cloud-sql-mysql.md)

The specified SQL statement is executed as a [prepared statement][mysql-prepare],
and expects parameters in the SQL query to be in the form of placeholders `?`.

[mysql-prepare]: https://dev.mysql.com/doc/refman/8.4/en/sql-prepared-statements.html

## Example

```yaml
tools:
search_flights_by_number:
kind: mysql-sql
source: my-mysql-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.
A airline code is a code for an airline service consisting of two-character
airline designator and followed by flight number, which is 1 to 4 digit number.
For example, if given CY 0123, the airline is "CY", and flight_number is "123".
Another example for this is DL 1234, the airline is "DL", and flight_number is "1234".
If the tool returns more than one option choose the date closes to today.
Example:
{{
"airline": "CY",
"flight_number": "888",
}}
Example:
{{
"airline": "DL",
"flight_number": "1234",
}}
parameters:
- name: airline
type: string
description: Airline unique 2 letter identifier
- name: flight_number
type: string
description: 1 to 4 digit number
```
## Reference
| **field** | **type** | **required** | **description** |
|-------------|:--------------------------------------------:|:------------:|-----------------------------------------------------------------------------------------------------|
| kind | string | true | Must be "mysql-sql". |
| source | string | true | Name of the source the SQL should execute on. |
| description | string | true | Description of the tool that is passed to the LLM. |
| statement | string | true | SQL statement to execute on. |
| parameters | [parameter](README.md#specifying-parameters) | true | List of [parameters](README.md#specifying-parameters) that will be inserted into the SQL statement. |
4 changes: 2 additions & 2 deletions docs/tools/postgres-sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ tools:
| **field** | **type** | **required** | **description** |
|-------------|:--------------------------------------------:|:------------:|-----------------------------------------------------------------------------------------------------|
| kind | string | true | Must be "postgres-generic". |
| kind | string | true | Must be "postgres-sql". |
| source | string | true | Name of the source the SQL should execute on. |
| description | string | true | Port to connect to (e.g. "5432") |
| description | string | true | Description of the tool that is passed to the LLM. |
| statement | string | true | SQL statement to execute on. |
| parameters | [parameter](README.md#specifying-parameters) | true | List of [parameters](README.md#specifying-parameters) that will be inserted into the SQL statement. |
Expand Down

0 comments on commit 90fbeba

Please sign in to comment.