| 1 |
# Cloud SQL proxy dialer for Go |
| 2 |
|
| 3 |
## Note |
| 4 |
|
| 5 |
This package is deprecated. Instead use the [Cloud SQL Go |
| 6 |
Connector][go-connector] which has support for MySQL, Postgres, and SQL Server, |
| 7 |
in addition to better configurability, support for metrics and tracing, and a |
| 8 |
number of additional features. See the [migration guide][migration-guide] for |
| 9 |
how to switch. |
| 10 |
|
| 11 |
## Overview |
| 12 |
|
| 13 |
You can also use the Cloud SQL proxy directly from a Go program. |
| 14 |
|
| 15 |
These packages are primarily used as implementation for the Cloud SQL proxy |
| 16 |
command, and may be changed in backwards incompatible ways in the future. |
| 17 |
|
| 18 |
## Usage |
| 19 |
|
| 20 |
If your program is written in [Go](https://golang.org) you can use the Cloud SQL |
| 21 |
Proxy as a library, avoiding the need to start the Proxy as a companion process. |
| 22 |
|
| 23 |
Alternatively, there are Cloud SQL Connectors for [Java][] and [Python][]. |
| 24 |
|
| 25 |
|
| 26 |
### MySQL |
| 27 |
|
| 28 |
If you're using the MySQL [go-sql-driver][go-mysql] you can use helper |
| 29 |
functions found in the [`proxy/dialers/mysql`][mysql-godoc] |
| 30 |
|
| 31 |
See [example usage](dialers/mysql/hook_test.go). |
| 32 |
|
| 33 |
### Postgres |
| 34 |
|
| 35 |
If you're using the Postgres [lib/pq](https://github.com/lib/pq), you can |
| 36 |
use the `cloudsqlpostgres` driver from [here](proxy/dialers/postgres). |
| 37 |
|
| 38 |
See [example usage](dialers/postgres/hook_test.go). |
| 39 |
|
| 40 |
[Java]: https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory |
| 41 |
[Python]: https://github.com/GoogleCloudPlatform/cloud-sql-python-connector |
| 42 |
[go-mysql]: https://github.com/go-sql-driver/mysql |
| 43 |
[mysql-godoc]: https://pkg.go.dev/github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql |
| 44 |
[go-connector]: https://pkg.go.dev/cloud.google.com/go/cloudsqlconn |
| 45 |
[migration-guide]: https://github.com/GoogleCloudPlatform/cloud-sql-go-connector/blob/main/migration-guide.md |