Skip to main content

One post tagged with "database"

View All Tags

Connect to Google Cloud SQL

· 5 min read

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.


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.

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.

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

Sign in to your Retool organization and create a new PostgreSQL resource from the Resources tab.

2. Configure the resource

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 settingDescription
HostThe publicly available IP address.
PortThe port number. Default is 5432.
Database nameThe name of the database.
Connection optionsAdditional connection options to use with Retool.

Select User and Password as the authentication method, then provide the following information.

Authentication settingDescription
Database usernameThe username.
Database passwordThe 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.

Configure user and password authentication

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.