# Connect PostgreSQL

Configure live sources and query them through the PostgreSQL wire protocol.

HTML: https://igloodb.github.io/docs/postgres/
Source: https://github.com/igloodb/igloodb/blob/b5a210d54a2e78a9a8c9497e2476061aad771d36/src/server.rs (connector preview b5a210d (unreleased))

## Prepare a PostgreSQL source

Have a reachable development PostgreSQL database and a PostgreSQL client such as psql. Create a small table in your own test database, or use an existing base table. Igloo discovers base tables in the configured schemas; views are skipped.

```sql
CREATE TABLE public.customers (
  id BIGINT PRIMARY KEY,
  name TEXT
);
INSERT INTO public.customers VALUES (1, 'Alex'), (2, 'Sam');
```

## Configure the engine

Save the following as igloo.toml. In the connector preview, native PostgreSQL does not require dummy Parquet or CDC directories. If you add the optional legacy parquet_path, that directory must exist.

When configured, the legacy iceberg table reads .parquet files with user_id: Int64 (non-null) and data: Utf8. Named parquet_sources infer general schemas; see Database connectors. Keep the OHLCV demo separate from the legacy path.

```toml
listen_addr = "127.0.0.1:5442"

[[sources]]
name = "app"
schemas = ["public"]
# Supply the URI with IGLOO_SOURCE_APP_URI.
```

## Start the SQL server

Set the source URI to your development database. Environment variables override file values. The serve command initializes the catalogs, result cache, and background CDC polling loop. Unlike plain cargo run, serve does not execute the standalone ADBC smoke test.

```text
export IGLOO_SOURCE_APP_URI='postgres://USER:PASSWORD@localhost:5432/DATABASE'
cargo run --locked -- serve
```

> The current server has no authentication or TLS. Keep listen_addr on localhost or a trusted, isolated development network. Authentication and TLS are roadmap work.

## Connect with psql

In another terminal, use the configured port to connect to Igloo. Canonical table names contain the source, schema, and table. SHOW TABLES and information_schema expose the federated catalog.

```text
psql -h 127.0.0.1 -p 5442 -U igloo -d igloo \
  -c 'SELECT * FROM app.public.customers;'

psql -h 127.0.0.1 -p 5442 -U igloo -d igloo \
  -c 'SHOW TABLES;'
```

> PostgreSQL wire compatibility covers simple queries and the extended query protocol. It does not imply full PostgreSQL SQL semantics, authentication, or compatibility with every BI tool. Client parameter types must match the inferred query types.
