Go 1.11 has reached end of support
and will be deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Go 1.11
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Go
1.11 applications will continue to run and receive traffic after their
deprecation date. We
recommend that you migrate to the latest supported version of Go.
Package cloudsql exposes access to Google Cloud SQL databases.
This package does not work in App Engine "flexible environment".
This package is intended for MySQL drivers to make App Engine-specific
connections. Applications should use this package through database/sql:
Select a pure Go MySQL driver that supports this package, and use sql.Open
with protocol "cloudsql" and an address of the Cloud SQL instance.
A Go MySQL driver that has been tested to work well with Cloud SQL
is the go-sql-driver:
Using either of these drivers, you can perform a standard SQL query.
This example assumes there is a table named 'users' with
columns 'first_name' and 'last_name':
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003ePackage cloudsql facilitates access to Google Cloud SQL databases within the App Engine standard environment.\u003c/p\u003e\n"],["\u003cp\u003eThis package is specifically designed for MySQL drivers to establish App Engine-specific connections, and is not compatible with the App Engine flexible environment.\u003c/p\u003e\n"],["\u003cp\u003eApplications should interact with this package through database/sql, using the "cloudsql" protocol along with the Cloud SQL instance address.\u003c/p\u003e\n"],["\u003cp\u003eThe package has been tested to work with pure Go MySQL drivers, specifically recommending "github.com/go-sql-driver/mysql" and "github.com/ziutek/mymysql/godrv".\u003c/p\u003e\n"],["\u003cp\u003eThe Dial function within the package establishes a connection to the specified Cloud SQL instance.\u003c/p\u003e\n"]]],[],null,["# Package google.golang.org/appengine/cloudsql (v1.6.8)\n\nVersion latestkeyboard_arrow_down\n\n- [1.6.8 (latest)](/appengine/docs/legacy/standard/go111/reference/latest/cloudsql)\n- [1.6.7](/appengine/docs/legacy/standard/go111/reference/1.6.7/cloudsql) \n**Note:** To get more information about this package, such as access to older versions, view [this package on pkg.go.dev](https://pkg.go.dev/google.golang.org/appengine/cloudsql). \n\u003cbr /\u003e\n\nPackage cloudsql exposes access to Google Cloud SQL databases.\n\nThis package does not work in App Engine \"flexible environment\".\n\nThis package is intended for MySQL drivers to make App Engine-specific\nconnections. Applications should use this package through database/sql:\nSelect a pure Go MySQL driver that supports this package, and use sql.Open\nwith protocol \"cloudsql\" and an address of the Cloud SQL instance.\n\nA Go MySQL driver that has been tested to work well with Cloud SQL\nis the go-sql-driver: \n\n```sql\nimport \"database/sql\"\nimport _ \"github.com/go-sql-driver/mysql\"\n\ndb, err := sql.Open(\"mysql\", \"user@cloudsql(project-id:instance-name)/dbname\")\n```\n\n\u003cbr /\u003e\n\nAnother driver that works well with Cloud SQL is the mymysql driver: \n\n```sql\nimport \"database/sql\"\nimport _ \"github.com/ziutek/mymysql/godrv\"\n\ndb, err := sql.Open(\"mymysql\", \"cloudsql:instance-name*dbname/user/password\")\n```\n\n\u003cbr /\u003e\n\nUsing either of these drivers, you can perform a standard SQL query.\nThis example assumes there is a table named 'users' with\ncolumns 'first_name' and 'last_name': \n\n```sql\nrows, err := db.Query(\"SELECT first_name, last_name FROM users\")\nif err != nil {\n log.Errorf(ctx, \"db.Query: %v\", err)\n}\ndefer rows.Close()\n\nfor rows.Next() {\n var firstName string\n var lastName string\n if err := rows.Scan(&firstName, &lastName); err != nil {\n log.Errorf(ctx, \"rows.Scan: %v\", err)\n continue\n }\n log.Infof(ctx, \"First: %v - Last: %v\", firstName, lastName)\n}\nif err := rows.Err(); err != nil {\n log.Errorf(ctx, \"Row error: %v\", err)\n}\n``` \n\nFunctions\n---------\n\n### func Dial\n\n func Dial(instance https://pkg.go.dev/builtin#string) (https://pkg.go.dev/net.https://pkg.go.dev/net#Conn, https://pkg.go.dev/builtin#error)\n\nDial connects to the named Cloud SQL instance."]]