Two Minute Reports Logo
Connectors

PostgreSQL

Connect PostgreSQL to Google Sheets or Google Data Studio

The PostgreSQL connector gets your PostgreSQL data into Google Sheets and Google Data Studio. Use it to track your key metrics in a spreadsheet or a Google Data Studio report.

What you can report on

  • Any custom data stored in your PostgreSQL database
  • Sales, orders, and transactional records from your systems
  • User activity and product engagement metrics
  • Operational and logistics data
  • Custom KPIs and business metrics specific to your product

Prerequisites

  • A PostgreSQL server accessible over the network
  • Database host, port, database name, username, and password
  • A database user with SELECT permissions on the tables you want to query
  • Your database firewall set to accept Two Minute Reports' IP addresses (see IP whitelisting below)

How to create a connection

  1. In the Hub, open Connections & accounts.
  2. Select Create connection.
  3. Select PostgreSQL in the connector list.
  4. Select Next.

  1. In Name the connection, enter a name.
  2. Enter your database details in DB host address, DB port, DB name, Username and Password.
  3. If your database needs an encrypted connection or an SSH tunnel, turn on Use SSL or Use SSH, and enter the details.
  4. Select Test connection.

  1. Enable the account.
  2. Select Done.

Only enabled accounts fetch data, and only enabled accounts count toward your plan. You can enable or disable accounts at any time on the Connections & accounts page.

How to get PostgreSQL data into Google Sheets or Google Data Studio

To get PostgreSQL data into Google Sheets:

  1. In the Two Minute Reports sidebar, open Data Queries.
  2. Select Add.
  3. Select your PostgreSQL account.
  4. In Execute (SQL Query), enter your SQL query.
  5. Select Run query. Two Minute Reports adds the data to your sheet.

Dynamic dates

In Google Data Studio, a query config with a custom SQL query can follow the date range of the report. Put @startdate and @enddate in the WHERE clause instead of fixed dates. Two Minute Reports replaces them with the report's date range each time the report gets data. You don't have to edit the dates in the SQL again.

Example: static query

SELECT * FROM orders
WHERE order_date BETWEEN '2024-01-01' AND '2024-01-31'

Same query with dynamic dates

SELECT * FROM orders
WHERE order_date BETWEEN @startdate AND @enddate
Write @startdate and @enddate in lowercase, as in the example. These parameters work in Google Data Studio query configs only. Google Sheets queries send the SQL as you wrote it.

Dynamic dates also keep reports fast, because the database returns only the rows for the selected dates instead of the full table.

IP whitelisting

Two Minute Reports connects from these fixed IP addresses. Add all 5 to your pg_hba.conf file before you create the connection. Allowing only some of them gives you a connection that works until a request leaves from one of the others.

49.13.34.182
5.75.217.220
116.203.164.91
95.216.182.151
91.99.28.86

Add the following lines to your pg_hba.conf file (replace your_database and your_user):

host  your_database  your_user  49.13.34.182/32    md5
host  your_database  your_user  5.75.217.220/32    md5
host  your_database  your_user  116.203.164.91/32  md5
host  your_database  your_user  95.216.182.151/32  md5
host  your_database  your_user  91.99.28.86/32     md5

After you edit it, reload PostgreSQL: pg_ctlcluster <version> main reload

Still blocked after adding all five? See Connection blocked by a firewall or IP allowlist.

Copyright © 2026