Skip to content
DocumentationLakehouse
Lakehouse
Explore and query
Connect a Postgres client

Connect a Postgres client

Use PostgreSQL syntax to query Altertable from psql, DBeaver, pgAdmin, or a BI tool. For client-specific setup, see Hex or Metabase.

Prerequisites

You need a PostgreSQL-compatible client, an Altertable catalog name, and lakehouse credentials for the target environment.

Connect

Set the host to postgres.altertable.ai, the port to 443, and the database to your catalog name. Enable TLS and authenticate with your lakehouse username and password.

psql

Terminal
PGSSLMODE=require psql -h postgres.altertable.ai -p 443 -U YOUR_LAKEHOUSE_USERNAME your_database

Python (psycopg2)

Python
import psycopg2
​
conn = psycopg2.connect(
host="postgres.altertable.ai",
port=443,
database="your_database",
user="YOUR_LAKEHOUSE_USERNAME",
password="YOUR_LAKEHOUSE_PASSWORD",
sslmode="require"
)

Run your first query

Run this in the connected client:

SQL
SELECT 1 AS ok;

The result should contain one row with an ok column equal to 1.

Postgres
-- Altertable speaks the Postgres wire protocol natively.
-- No SDK needed — any Postgres client works out of the box.
​
-- psql
psql "postgresql://YOUR_LAKEHOUSE_USERNAME:[email protected]:443/my_db"

Troubleshooting

Unrecognized PostgreSQL function

The adapter translates PostgreSQL queries for the lakehouse. If a function call fails, check the function name and argument types. If the same call works in PostgreSQL, include the query and error message when contacting support.

TLS negotiation

The Postgres adapter supports standard PostgreSQL SSL negotiation on port 443.

If a connection times out before authentication, check whether your network performs TLS inspection on port 443. Some configurations, including Cloudflare Gateway TLS inspection, may reject PostgreSQL's plaintext SSLRequest preamble.

  • Preferred: bypass TLS inspection for postgres.altertable.ai.
  • For clients using libpq 17 or newer, add sslnegotiation=direct alongside sslmode=require.
  • Clients without TLS-direct support, including Node pg, require the network bypass.