databricks-lakebase-autoscale
Patterns and best practices for Lakebase Autoscaling (next-gen managed PostgreSQL). Use when creating or managing Lakebase Autoscaling projects, configuring autoscaling compute or scale-to-zero, working with database branching for dev/test workflows, implementing reverse ETL via synced tables, or connecting applications to Lakebase with OAuth credentials.
What this skill does
# Lakebase Autoscaling
Lakebase Autoscaling is Databricks' next-generation managed PostgreSQL service for OLTP workloads: autoscaling compute, database branching, scale-to-zero, instant restore, and Delta-to-Postgres synced tables.
Use this skill when creating/managing Lakebase Autoscaling projects, branches, endpoints/computes, credentials, reverse ETL synced tables, or app connections.
## Core framing
> **There is no separate Python “Lakebase SDK.”** Use `databricks-sdk` for management and for minting short-lived database credentials with `WorkspaceClient().postgres.generate_database_credential(...)`; use standard Postgres drivers (`psycopg`, SQLAlchemy, JDBC, `pgx`, etc.) for SQL.
| Language | Credential / management SDK | DB driver / wrapper |
|---|---|---|
| **Python** | `databricks-sdk` `WorkspaceClient().postgres` | `psycopg[binary,pool]` canonical; SQLAlchemy supported |
| **Node/TS** | `@databricks/lakebase` convenience wrapper, Autoscaling only | Wrapper manages `pg` pool |
| **Java/Go** | Databricks SDK for Java/Go | Standard JDBC / `pgx` |
## Lead connection pattern
For production Python apps, start with:
1. `psycopg_pool.ConnectionPool`
2. `connection_class=OAuthConnection`, where `OAuthConnection(psycopg.Connection).connect()` calls `w.postgres.generate_database_credential(endpoint=...)`
3. `max_lifetime=2700`
This is the canonical pattern from the official Databricks Apps + Lakebase Autoscaling tutorial lineage and `databricks-ai-bridge`: no background token thread; physical connections get fresh credentials when opened/recycled.
Prefer `max_lifetime=2700` as a defensive 45-minute recycle before 1-hour token expiry. The official tutorial does not set `max_lifetime`; `databricks-ai-bridge` uses `2700`.
See `connections.md`.
## Critical auth warning
Do **not** use `WorkspaceClient().config.token`, `w.config.oauth_token().access_token`, or any workspace-scoped OAuth token as the Postgres password. It will fail at Postgres login.
Use:
```python
cred = WorkspaceClient().postgres.generate_database_credential(endpoint=endpoint_name)
password = cred.token
```
That token is Lakebase-scoped and is used as the Postgres password with `sslmode=require`.
## Resource model
```text
Project
└── Branches
├── Endpoint/Compute: primary read-write endpoint
├── Read replicas: optional read-only endpoints
├── Roles
└── Databases
└── Schemas/Tables
```
Canonical names:
```text
projects/{project_id}
projects/{project_id}/branches/{branch_id}
projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id}
```
Defaults on project creation:
- default branch: `production`
- default database: `databricks_postgres`
- primary read-write endpoint/compute
- Postgres role for the creator’s Databricks identity
Key SDK namespace: `WorkspaceClient().postgres`.
Most create/update/delete calls return long-running operations; call `.wait()`.
## Lakebase Autoscaling vs Provisioned
| Aspect | Provisioned | Autoscaling |
|---|---|---|
| SDK module | `w.database` | `w.postgres` |
| Top-level resource | Instance | Project |
| Capacity | fixed CU tiers, ~16 GB/CU | 0.5–112 CU, ~2 GB/CU |
| Branching | no | yes |
| Scale-to-zero | no | yes |
| Operations | mostly synchronous | LROs; use `.wait()` |
| Reverse ETL | synced tables | synced tables |
| Read replicas | readable secondaries | dedicated read-only endpoints |
## Non-obvious facts to preserve
- Postgres versions: **16 and 17**.
- AWS regions: `us-east-1`, `us-east-2`, `eu-central-1`, `eu-west-1`, `eu-west-2`, `ap-south-1`, `ap-southeast-1`, `ap-southeast-2`.
- Azure beta regions: `eastus2`, `westeurope`, `westus`.
- Autoscaling computes: 0.5–32 CU with `max - min <= 16`.
- Fixed-size always-on computes: 40–112 CU.
- Autoscaling CU ≈ 2 GB RAM.
- `sslmode=require` on all driver connections.
- Endpoint host comes from `w.postgres.get_endpoint(...).status.hosts.host`.
- GET responses often return effective properties under `status`; create/update payloads use `spec`.
- All update calls need a `FieldMask`.
- Scale-to-zero wake-up is automatic but apps should retry.
- Connections can be closed by platform timeouts: 24-hour idle timeout and 3-day max connection lifetime.
- macOS DNS can fail on long Lakebase hostnames; if so, resolve to IP and pass both `host` and `hostaddr` to psycopg.
- Triggered/Continuous synced tables require Delta Change Data Feed.
- Reverse ETL is Delta-to-Postgres only; not Postgres-to-Delta.
## Task files
- `connections.md` — app/notebook connection patterns and credential rotation.
- `operations.md` — project, branch, endpoint/compute, scale-to-zero, limits, MCP mapping.
- `reverse-etl.md` — synced tables from Delta Lake to Lakebase.
## SDK / package versions
```bash
pip install -U "databricks-sdk>=0.81.0" "psycopg[binary,pool]>=3.1" "sqlalchemy>=2"
```
Use SQLAlchemy URL prefix `postgresql+psycopg://...` for psycopg3.
## Current limitations
Not yet supported or not equivalent to Provisioned:
- High availability with readable secondaries; use read replicas instead.
- Databricks Apps UI integration may lag; Apps can connect manually via credentials/resource env vars.
- Feature Store integration.
- Stateful AI-agent memory integrations.
- Postgres-to-Delta sync.
- Custom billing tags / serverless budget policies.
- Direct migration from Lakebase Provisioned; use `pg_dump`/`pg_restore` or reverse ETL patterns where appropriate.
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.