Postgres

@db-sdk/postgres — Postgres reads for DB SDK

@db-sdk/postgres is the shared Postgres driver. Raw URI connections and hosted providers (Supabase) both use it.

import { connect } from "@db-sdk/core";
import { postgres } from "@db-sdk/postgres";

const db = await connect({
  provider: postgres({
    connectionString: process.env.DATABASE_URL,
  }),
});

await db.test();
const catalog = await db.introspect();
const result = await db.query({
  sql: "SELECT id, email FROM users WHERE plan = $1",
  params: ["pro"],
});

id defaults to "postgres". driver is always "postgres". Hosted providers pass their own id and reuse this driver.

Safety

  • Rejects non-SELECT / non-WITH … SELECT and multi-statement batches (best-effort)
  • Prefer a read-only database role — SDK checks are not the security boundary

Hosted providers

postgres({
  id: "<product>",
  connectionString: resolvedUri,
});

Do not reimplement SQL policy in the hosted package.

Options

Prop

Type

Query

Prop

Type

npm install @db-sdk/core @db-sdk/postgres

On this page