Skip to content

pgaddress

Flexible address parser for Lakebase Postgres connection inputs.

Accepts whatever shape a user is likely to paste into LAKEBASE_ENDPOINT (or the matching config field) and extracts every recognizable piece. Whatever it can’t recover is left for the Lakebase resolver to discover.

Recognized formats:

  • Postgres URI - postgresql://user@host:port/db?sslmode=require (also postgres://). Yields user, host, port, database, sslMode.

  • Canonical endpoint resource path - projects/{p}/branches/{b}/endpoints/{e} - yields project, branch, endpointId, and the original string as endpoint (already in lakebase’s expected form).

  • Database resource path - projects/{p}/branches/{b}/databases/{d} - yields project, branch, and databaseResourceId (the UC resource leaf, not PGDATABASE; the resolver looks up the real Postgres name via REST).

  • Branch resource path - projects/{p}/branches/{b} - yields project, branch.

  • Project resource path - projects/{p} - yields project.

  • Bare hostname - ep-steep-forest-e199v43w.database.eastus2.azuredatabricks.net - yields host only; the resolver reverse-looks up the owning endpoint to recover the resource path.

  • Bare project id - dbx-tools-demo (1-63 chars, lowercase letters/digits/hyphens) - yields project.

Returns an empty object for inputs it doesn’t recognize.