PostgreSQL
Databricks Lakebase
Connect Artie to a Databricks Lakebase Postgres destination with OAuth, using a Databricks service principal instead of a database password.
Use this for a Databricks Lakebase Postgres destination when you don’t want to allow native Postgres password logins. Artie signs in as a Databricks service principal and requests a short-lived Postgres credential for every new connection, so no database password is stored. For other PostgreSQL databases, or Lakebase with a password role, follow the PostgreSQL destination setup.
What you’ll need:
- A Lakebase project. Instances upgraded from Lakebase Provisioned work too.
- Permission to create a service principal and generate an OAuth secret for it in the workspace.
- A Databricks OAuth sign-in to the Lakebase database with
CREATEandCREATE ROLE, such as the project owner.
Setup
Create a service principal
In your workspace, go to Settings > Identity and access > Service principals and add a service principal for Artie. On its Configurations tab, enable Workspace access. Lakebase only issues database credentials to service principals that have it.
On the Secrets tab, select Generate secret, then copy the client ID and the secret. The secret is only shown once, and the client ID is the same as the service principal’s application ID. Artie requests the
all-apisscope, so the secret must allow it. Rotate the secret in Artie before it expires.Create the service principal's Postgres role
In the Lakebase App, open your project’s SQL Editor, select the branch and the
databricks_postgresdatabase, and run the following while signed in with Databricks OAuth. Sessions that signed in with a Postgres password can’t create OAuth roles.SQLCREATE EXTENSION IF NOT EXISTS databricks_auth; -- The role name is the service principal's client ID (case-sensitive). SELECT databricks_create_role('6f1c2a7e-3b4d-4e8f-9a0b-1c2d3e4f5a6b', 'SERVICE_PRINCIPAL'); -- New OAuth roles can only log in. Allow connecting and creating the schemas Artie needs. GRANT CONNECT, CREATE ON DATABASE databricks_postgres TO "6f1c2a7e-3b4d-4e8f-9a0b-1c2d3e4f5a6b"; -- If the target schema already exists, allow creating tables in it. GRANT USAGE, CREATE ON SCHEMA analytics TO "6f1c2a7e-3b4d-4e8f-9a0b-1c2d3e4f5a6b";Artie owns the schemas and tables it creates, so it can run DDL such as
ALTER TABLEon them. Lakebase doesn’t support transferring ownership with a plainALTER ... OWNER TO, so grant access to an existing schema instead.Find the connection details
In the Lakebase App, open your project’s Branches page, select the branch, and open its Computes tab.
- Host: select Connect and copy the host. Use the compute’s direct host, not the
-poolerhost, because Lakebase connection pooling doesn’t support OAuth roles. - Endpoint: in the compute’s Get ID menu, copy the Resource name, for example
projects/my-project/branches/production/endpoints/primary. You can also list them withdatabricks postgres list-endpoints projects/<project-id>/branches/<branch-id>. - Workspace host: your workspace’s hostname without
https://, for exampledbc-1234abcd-5678.cloud.databricks.com.
- Host: select Connect and copy the host. Use the compute’s direct host, not the
Add the destination in Artie
Create a PostgreSQL destination and select Databricks Lakebase OAuth as the authentication method. Enter the host, port
5432, workspace host, endpoint, client ID, and client secret. Usedatabricks_postgresas the database unless you created another one.
Advanced
How Artie uses the OAuth credentials
- Artie exchanges the client ID and secret for a workspace OAuth token, then calls the Lakebase credentials API for a Postgres credential that’s valid for 60 minutes. It caches the credential and requests a new one shortly before it expires.
- Lakebase only checks the credential at sign-in, so open connections stay open after it expires. New connections use the current credential.
- Artie always connects to Lakebase over TLS.
Writing to tables that another role owns
Artie can write rows to existing tables owned by another role if you grant it SELECT, INSERT, UPDATE, DELETE on them, but schema changes such as ALTER TABLE need ownership. To move ownership to the service principal, use Lakebase’s temporary shared role procedure.
Network access
Choosing OAuth over password sign-in doesn’t change who can reach the database. Network access is controlled separately, through your workspace’s IP access lists and ingress policies or Private Link. Allow Artie’s IP addresses, or connect through PrivateLink.