Skip to content
Learn › Connectors: open the docs menu

PostgreSQL connector

The PostgreSQL connector imports data from your PostgreSQL database into Mammoth as a dataset. You can import tables directly or write custom SQL queries to select specific rows and columns. When enabled for your workspace, AI query generation creates SQL from plain-language descriptions; you can also edit queries manually. You can refresh the dataset manually or on a schedule.

Before you start

You need:

  • A PostgreSQL server accessible from the internet
  • A database user with SELECT permission on the tables you want to import
  • Your server's hostname or IP address, port (default: 5432), database name, username, and password
  • Mammoth's IP address added to your PostgreSQL firewall allowlist—see Network requirements

Step 1: Select the PostgreSQL connector

  1. In Mammoth, go to Data Library and click + New Dataset
  2. Select Connectors
  3. Search for PostgreSQL
  4. Click the PostgreSQL tile

Step 2: Create a connection

Click New Connection to open the credential form.

PostgreSQL New Connection form with Host URL, Port, Username, Password, Database, and Display Name fields

Fill in the following fields:

FieldDescriptionExample
Host URLHostname or IP address of your PostgreSQL serveranalytics-prod.example.com
PortTCP port PostgreSQL listens on5432 (default)
UsernameDatabase user with SELECT accessmammoth_reader
PasswordPassword for the database user—
DatabaseName of the database to connect toanalytics_prod
Display NameOptional label for this connection in MammothPostgres Production

Mammoth needs network access. Your PostgreSQL server must allow inbound connections from Mammoth's IP address, which the connection form shows. See Network requirements for firewall configuration steps.

After filling in the fields, click Connect. Mammoth validates the credentials and saves the connection; if validation fails, the error message appears at the bottom of the form.


Step 3: Query your PostgreSQL data

After connecting, your connection appears under Existing Connections. Select it to open the query builder, which has a table browser and two options for specifying your data:

Select a PostgreSQL schema

PostgreSQL databases can have multiple schemas (the default is public). Mammoth lists them under Schema below your connection; click the schema that contains your tables. If the database has only one schema, Mammoth opens it automatically.

Browse and select PostgreSQL tables

The List of tables panel lists all tables in the selected schema. Click a table name to load a SELECT * query for it and its preview.

Generate a PostgreSQL query with AI

When enabled for your workspace, the Describe the data you need... box appears above the query editor. Use it to tell Mammoth what you want in plain language—for example, "all completed orders in the last 90 days"—and click the generate button. Mammoth writes the SQL query based on your table structure and description. The box is disabled while Mammoth sets up metadata for AI query.

Write a custom PostgreSQL query

Alternatively, write or edit SQL directly in the Enter SQL query field to filter rows, join tables, or select specific columns:

SELECT order_id, customer_id, amount, created_at
FROM orders
WHERE created_at >= NOW() - INTERVAL '90 days'
  AND status = 'completed'

Click Run to execute and preview the results.

PostgreSQL New Dataset dialog with table list, SQL query, data preview, Save table as field, and Save as dataset button

See Understanding data preview & query for a full guide to the preview screen.

Step 4: Save the PostgreSQL dataset

When the preview looks correct:

  1. Enter a dataset name in the Save table as field (e.g., "PostgreSQL Orders")
  2. Check the Update Method (the default is Replace all data). To change it, click the edit icon, pick an option, and click Save changes:
    • Replace all data—Replaces all existing data
    • Add new data—Adds new data based on a unique sequential column
    • Replace with new data—Replaces existing data with new data based on a unique sequential column For Add new data and Replace with new data, also choose a Key column—a numeric or date column with incrementing values, such as an ID or a date.
  3. Click Save as dataset. When the dataset is saved, click Done

Your dataset appears in the Data Library and is ready to use in pipelines and dashboards.

Keep PostgreSQL data up to date

To refresh your PostgreSQL dataset on a schedule, create a Dataset Refresh automation. This re-runs your query and updates the dataset according to your update method. You can also run it manually.

Troubleshoot PostgreSQL connections

Connection fails

  • Confirm Mammoth's IP address is in your PostgreSQL allowlist (pg_hba.conf and any cloud security group)
  • Check the hostname and port are correct
  • Verify the database user can connect from an external host (not just localhost)

No tables appear in the table browser

  • Your database user may lack SELECT permission—run GRANT SELECT ON ALL TABLES IN SCHEMA public TO your_user;
  • Verify the database connection succeeded and the database user has access to your tables

Query returns unexpected results

  • Test the query directly in your PostgreSQL client before running it in Mammoth
  • Check for timezone differences if filtering by date

Report an issue · support@mammoth.io