Looker supports connections to AlloyDB for PostgreSQL, a fully managed, cloud-native database service from Google Cloud that is compatible with PostgreSQL.
This page provides the instructions for connecting to AlloyDB for PostgreSQL from Looker.
Encrypting network traffic
It is a best practice to encrypt network traffic between the Looker application and your database. Consider one of the options that are described on the Enabling secure database access documentation page.
If you're interested in using SSL encryption, see the PostgreSQL documentation.
Users and security
To perform actions on your database, Looker needs to have a user account on your database.
To configure a database user for Looker to use, perform the following steps on your database:
Create a database user and password.
CREATE USER USERNAME WITH ENCRYPTED PASSWORD 'PASSWORD';Grant permissions to the database user so that Looker can perform actions on your database:
GRANT CONNECT ON DATABASE DATABASE_NAME to USERNAME; \c DATABASE_NAME GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO USERNAME; GRANT SELECT ON ALL TABLES IN SCHEMA public TO USERNAME;If you're using a schema other than
public, run this command to grant usage permissions to Looker:GRANT USAGE ON SCHEMA SCHEMA_NAME TO USERNAME;To make sure that future tables that you add to the public schema are also available to the Looker user, run these commands:
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON tables TO USERNAME; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON sequences TO USERNAME;
Depending on your setup, the preceding commands may need to be altered. If another user or role is creating tables that the Looker user needs future permissions for, you must specify a target role or user to apply the Looker user's permission grants to:
ALTER DEFAULT PRIVILEGES FOR USER ANOTHER_USERNAME IN SCHEMA SCHEMA_NAME GRANT SELECT ON tables TO USERNAME;
ALTER DEFAULT PRIVILEGES FOR ROLE TARGET_ROLE IN SCHEMA SCHEMA_NAME GRANT SELECT ON sequences TO USERNAME;
For example, if a web_app user creates tables and you want the looker user to be able to use those tables, you must run a GRANT statement to give the looker user permissions on tables that are created by the web_app user. The target role or user in this case is the web_app user, which means that you want to alter privileges on tables that are created by web_app so that the looker user can have permissions to read the tables. Here is an example:
ALTER DEFAULT PRIVILEGES FOR USER web_app IN SCHEMA public GRANT SELECT ON tables TO looker;
See ALTER DEFAULT PRIVILEGES on PostgreSQL's website for more information.
Temp schema setup
Create a schema owned by the Looker user:
CREATE SCHEMA SCHEMA_NAME AUTHORIZATION USERNAME;
Setting the search_path
Before connecting Looker to your database, you should set an appropriate search_path, which the Looker SQL Runner can use to retrieve certain metadata from your database:
ALTER USER USERNAME SET search_path TO '$user',SCHEMA_NAME,SCHEMA_NAME_2,SCHEMA_NAME_3
^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^
include a comma-separated list of
all schemas that you'll use with Looker
Creating the Looker connection to your database
Follow these steps to create the connection from Looker to your database:
Open the Connect your database to Looker page by doing one of the following:
- Click the Main menu icon and select Admin, and then select Connections from the Database section in the Admin panel. On the Connections page, click the Add Connection button.
- Click the Create button in the main navigation menu, and then select the Connection menu item.
From the Dialect drop-down menu, select Google Cloud AlloyDB for PostgreSQL.
Fill out the connection details. The majority of the settings are common to most database dialects. See the Connecting Looker to your database documentation page for more information.
To verify that the connection was successful, click Test. See the Testing database connectivity documentation page for troubleshooting information.
To save these settings, click Connect.
Feature support
For Looker to support some features, your database dialect must also support them.
Google Cloud AlloyDB for PostgreSQL supports the following features as of Looker 26.2:
| Feature | Supported? |
|---|---|
| Looker (Google Cloud core) | |
| Symmetric aggregates | |
| Derived tables | |
| Persistent SQL derived tables | |
| Persistent native derived tables | |
| Stable views | |
| Query killing | |
| SQL-based pivots | |
| Timezones | |
| SSL | |
| Subtotals | |
| JDBC additional params | |
| Case sensitive | |
| Location type | |
| List type | |
| Percentile | |
| Distinct percentile | |
| SQL Runner Show Processes | |
| SQL Runner Describe Table | |
| SQL Runner Show Indexes | |
| SQL Runner Select 10 | |
| SQL Runner Count | |
| SQL Explain | |
| OAuth 2.0 credentials | |
| Context comments | |
| Connection pooling | |
| HLL sketches | |
| Aggregate awareness | |
| Incremental PDTs | |
| Milliseconds | |
| Microseconds | |
| Materialized views | |
| Period-over-period measures | |
| Approximate count distinct |