This page contains code samples for Cloud SQL for MySQL. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.
Configure SSL certificates for TCP connection by using Go
Configure SSL (Secure Sockets Layer) certificates for a TCP connection to Cloud SQL for MySQL by using Go's database/sql package.
Configure SSL certificates for TCP connection by using Python
Configure SSL (Secure Sockets Layer) certificates for a TCP connection to Cloud SQL for MySQL by using Python's sqlalchemy package.
Create a connection using the Cloud SQL Go Connector
Open a connection to Cloud SQL for MySQL by using the Cloud SQL Go Connector.
Create a connection using the Cloud SQL Java Connector
Open a connection to Cloud SQL for MySQL by using the Cloud SQL Java Connector.
Create a connection using the Cloud SQL Python Connector
Open a connection to Cloud SQL for MySQL by using the Cloud SQL Python Connector.
Create a socket connection by using Go
Open a Unix socket connection to Cloud SQL for MySQL by using Go's database/sql package.
Create a socket connection by using Java
Open a Unix socket connection to Cloud SQL for MySQL by using Java.
Create a socket connection by using PHP
Open a Unix socket connection to Cloud SQL for MySQL by using PHP.
Create a socket connection by using Python
Open a Unix socket connection to Cloud SQL for MySQL by using Python.
Create a socket connection when using ADO.NET
Open a Unix socket connection to Cloud SQL for MySQL by using an ADO.NET Connection object.
Create a socket connection when using Node.js
Open a Unix socket connection to Cloud SQL for MySQL by using the Node.js npm mysql module.
Create a TCP connection by using Go
Open a TCP connection to Cloud SQL for MySQL by using Go's database/sql package.
Create a TCP connection by using Java
Open a TCP connection to Cloud SQL for MySQL by using Java
Create a TCP connection by using Python
Open a TCP connection to Cloud SQL for MySQL by using Python.
Create a TCP connection when using ADO.NET
Open a TCP connection to Cloud SQL for MySQL by using an ADO.NET Connection object.
Create a TCP connection when using Node.js
Open a TCP connection to Cloud SQL for MySQL by using the Node.js npm mysql module.
Create a TCP connection with SSL certificates when using Node.js
Open a TCP connection to Cloud SQL for MySQL by using the Node.js npm mysql module with SSL (Secure Sockets Layer) certificates.
Implement exponential backoff when using ADO.NET
Implement exponential backoff to retry failed connections when connecting to Cloud SQL for MySQL by using ADO.NET with the Polly .NET library.
View in documentation
Manage connections by using ActiveRecord
Insert data using ActiveRecord to manage opening and closing a connection to Cloud SQL for MySQL.
View in documentation
MySQL PDO connection
Run a SQL INSERT statement to open and close a connection to Cloud SQL for MySQL by using the PHP Data Objects (PDO) extension.
View in documentation
MySQL servlet connection
Run a SQL INSERT statement to open and close a connection to Cloud SQL for MySQL by using the HikariCP JDBC connection pool library.
View in documentation
MySQL SQLAlchemy opening and closing connections
Run a SQL INSERT statement to open and close a connection to Cloud SQL for MySQL by using SQLAlchemy.
View in documentation
MySQL—mysql connection
Run a SQL INSERT statement by opening and closing a connection to Cloud SQL for MySQL by using the Node.js mysql module.
View in documentation
Open or close a connection when using ADO.NET
Run a SQL INSERT statement to open and close a connection to Cloud SQL for MySQL by using the ADO.NET System.Data.Common package.
Retry a failed connection when using HikariCP
Retry a failed connection when connecting to Cloud SQL for MySQL by using the HikariCP JDBC connection pool library.
View in documentation
Retry a failed connection when using Node.js
Retry a failed connection when connecting to Cloud SQL for MySQL by using the Node.js npm mysql module.
View in documentation
Retry a failed connection when using SQLAlchemy
Retry a failed connection when connecting to Cloud SQL for MySQL by using SQLAlchemy.
View in documentation
Run an SQL INSERT statement using Go
Run an SQL INSERT statement by opening and closing a connection to Cloud SQL for MySQL using Go's database/sql package.
View in documentation
Set connection pool and overflow limits when using ADO.NET
Configure the connection pool size and overflow when connecting to Cloud SQL for MySQL by using the ADO.NET Connection object.
View in documentation
Set connection pool and overflow limits when using Go
Configure the connection pool size and overflow when connecting to Cloud SQL for MySQL by using Go's database/sql package.
View in documentation
Set connection pool and overflow limits when using HikariCP
Configure the connection pool size and overflow when connecting to Cloud SQL for MySQL by using the HikariCP JDBC connection pool library.
View in documentation
Set connection pool and overflow limits when using Node.js
Configure the connection pool size and overflow when connecting to Cloud SQL for MySQL using the Node.js npm mysql module.
View in documentation
Set connection pool and overflow limits when using SQLAlchemy
Configure the connection pool size and overflow when connecting to Cloud SQL for MySQL by using SQLAlchemy.
View in documentation
Set the connection duration when using ADO.NET
Configure the maximum number of seconds a connection can persist when connecting to Cloud SQL for MySQL by using the ADO.NET Connection object.
View in documentation
Set the connection duration when using HikariCP
Set the maximum number of seconds a connection can persist when connecting to Cloud SQL for MySQL by using the HikariCP JDBC connection pool library.
View in documentation
Set the connection duration when using SQLAlchemy
Configure the maximum number of seconds a connection can persist when connecting to Cloud SQL for MySQL by using SQLAlchemy.
View in documentation
Set the connection timeout when using ADO.NET
Configure a connection timeout when connecting to Cloud SQL for MySQL by using the ADO.NET Connection object.
View in documentation
Set the connection timeout when using Go
Configure a connection timeout when connecting to Cloud SQL for MySQL by using Go's database/sql package.
View in documentation
Set the connection timeout when using HikariCP
Configure a connection timeout when connecting to Cloud SQL for MySQL by using the HikariCP JDBC connection pool library.
View in documentation
Set the connection timeout when using Node.js
Configure a connection timeout when connecting to Cloud SQL for MySQL by using the Node.js npm mysql module.
View in documentation
Set the connection timeout when using PHP
Configure a connection timeout when connecting to Cloud SQL for MySQL by using the PHP Data Objects (PDO) extension.
View in documentation
Set the connection timeout when using SQLAlchemy
Configure the connection timeout when connecting to Cloud SQL for MySQL by using SQLAlchemy.
View in documentation