Connect to Google Cloud SQL
You can connect to Google Cloud SQL and make your managed PostgreSQL or MySQL databases available as resources in Retool. Once complete, your users can write queries that interact with your data.
Requirements
All users for Retool organizations on Free or Team plans have global Edit permissions and can add, edit, and remove resources. If your organization manages user permissions for resources, you must be a member of a group with Edit all permissions.
- PostgreSQL
- MySQL
To create a PostgreSQL resource, you need:
- Cloud SQL authentication credentials for the PostgreSQL database.
- Connection details for the PostgreSQL database host. This includes the hostname, port, and database name.
- Firewall rules that allow Retool to access Cloud SQL.
Retool authenticates with Cloud SQL for PostgreSQL databases using a username and password. You should create an additional user for this purpose and not reuse existing credentials. This provides more granular control and allows you to manage the scope of permissions.
To create a MySQL resource, you need:
- Cloud SQL authentication credentials for the MySQL database.
- Connection details for the MySQL database host. This includes the hostname, port, and database name.
- Firewall rules that allow Retool to access Cloud SQL.
Retool authenticates with Cloud SQL for PostgreSQL databases using a username and password. You should create an additional user for this purpose and not reuse existing credentials. This provides more granular control and allows you to manage the scope of permissions.
You must allow access from Retool's IP addresses. Add the IP addresses to your firewall's Allowlist before you create the resource. Refer to the Cloud SQL documentation for guidance on authorizing access to Cloud SQL.
1. Create the resource
- PostgreSQL
- MySQL
Sign in to your Retool organization and create a new PostgreSQL resource from the Resources tab.
Sign in to your Retool organization and create a new MySQL resource from the Resources tab.
2. Configure the resource
- PostgreSQL
- MySQL
Specify a name and location for the PostgreSQL resource. Retool displays the resource name and type in query editors to help users identify them.
Next, configure the General and Authentication settings.
General setting | Description |
---|---|
Host | The publicly available IP address. |
Port | The port number. Default is 5432 . |
Database name | The name of the database. |
Connection options | Additional connection options to use with Retool. |
Select User and Password as the authentication method, then provide the following information.
Authentication setting | Description |
---|---|
Database username | The username. |
Database password | The password. |
Specify whether to connect using SSL. PostgreSQL resources are initially configured to use SSL by default. If required, you can provide CA certificate, client key, and client certificate credentials.
Specify a name and location for the MySQL resource. Retool displays the resource name and type in query editors to help users identify them.
Next, configure the General and Authentication settings.
General setting | Description |
---|---|
Host | The publicly available IP address. |
Port | The port number. Default is 3306 . |
Database name | The name of the database. |
Connection options | Additional connection options to use with Retool. |
Select User and Password as the authentication method, then provide the following information.
Authentication setting | Description |
---|---|
Database username | The username. |
Database password | The password. |
Specify whether to connect using SSL. MySQL resources are initially configured to use SSL by default. If required, you can provide CA certificate, client key, and client certificate credentials.
3. Test and save
Click Test Connection to verify that Retool can connect to Cloud SQL. If the test fails, check the resource settings and try again. Testing a connection only checks whether Retool can successfully connect to the resource. It cannot check whether the provided credentials have sufficient privileges or can perform every supported action.
Click Create resource to complete the setup. You can then click either Create app to immediately start building a Retool app or Back to resources to return to the list of resources.
Wrap up
Your Cloud SQL resource is now ready to use. To interact with Cloud SQL data, select the resource in the query editor. You can read data using SQL queries, write data using GUI queries (if enabled), and use the schema browser to search tables or columns.