You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -257,7 +257,7 @@ const result = await pool.query('SELECT * FROM users');
257
257
```
258
258
259
259
**ORM Integration:**
260
-
Works with Drizzle, Prisma, TypeORM - see [Lakebase Integration Docs](docs/docs/integrations/lakebase.md) for examples.
260
+
Works with Drizzle, Prisma, TypeORM - see the [`@databricks/lakebase` README](https://github.com/databricks/appkit/blob/main/packages/lakebase/README.md) for examples.
Copy file name to clipboardExpand all lines: docs/docs/api/appkit/index.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,5 +73,6 @@ plugin architecture, and React integration.
73
73
|[getLakebasePgConfig](Function.getLakebasePgConfig.md)| Get Lakebase connection configuration for PostgreSQL clients. |
74
74
|[getPluginManifest](Function.getPluginManifest.md)| Loads and validates the manifest from a plugin constructor. Normalizes string type/permission to strict ResourceType/ResourcePermission. |
75
75
|[getResourceRequirements](Function.getResourceRequirements.md)| Gets the resource requirements from a plugin's manifest. |
76
+
|[getUsernameWithApiLookup](Function.getUsernameWithApiLookup.md)| Resolves the PostgreSQL username for a Lakebase connection. |
76
77
|[getWorkspaceClient](Function.getWorkspaceClient.md)| Get workspace client from config or SDK default auth chain |
77
78
|[isSQLTypeMarker](Function.isSQLTypeMarker.md)| Type guard to check if a value is a SQL type marker |
You can obtain the Project ID and Branch ID from the Lakebase Autoscaling UI, like the "Branch Overview" page. (Project list -> Project dashboard -> Branch overview). When using the driver as a part of Databricks Apps, the `LAKEBASE_ENDPOINT` is automatically injected using `fromValue`:
46
-
47
-
```yaml
48
-
env:
49
-
- name: LAKEBASE_ENDPOINT
50
-
valueFrom: database # Lakebase Autoscaling database resource name
51
-
```
45
+
You can obtain the Project ID and Branch ID from the Lakebase Autoscaling UI, like the "Branch Overview" page. (Project list -> Project dashboard -> Branch overview).
52
46
53
47
Then use the driver:
54
48
@@ -85,14 +79,43 @@ The driver supports Databricks authentication via:
85
79
86
80
See [Databricks authentication docs](https://docs.databricks.com/en/dev-tools/auth/index.html) or [Lakebase Autoscaling authentication docs](https://docs.databricks.com/aws/en/oltp/projects/authentication#overview) for more information.
87
81
82
+
## PostgreSQL Username Resolution
83
+
84
+
The driver resolves the PostgreSQL username (`user` configuration option) using the following priority order:
85
+
86
+
1.`config.user` — explicit value passed to `createLakebasePool`
87
+
2.`PGUSER` environment variable
88
+
3.`DATABRICKS_CLIENT_ID` environment variable (service principals using OAuth M2M)
89
+
90
+
If none of these are set, the driver throws a `ConfigurationError`.
91
+
92
+
### Automatic resolution via Workspace API
93
+
94
+
For human users authenticating with a PAT token or browser OAuth via `~/.databrickscfg`, none of the above are typically set. Use `getUsernameWithApiLookup` to automatically fetch the username from the Databricks workspace before creating the pool:
// Tries config/env vars first, then falls back to currentUser.me() API call
100
+
const user =awaitgetUsernameWithApiLookup();
101
+
102
+
const pool =createLakebasePool({ user });
103
+
```
104
+
105
+
`getUsernameWithApiLookup` extends the sync resolution above with a fourth step:
106
+
107
+
4.`currentUser.me()` — fetches the current user's identity from the Databricks workspace API (works with PAT tokens and browser OAuth in `~/.databrickscfg`)
108
+
109
+
> **Note:**`getUsernameWithApiLookup` makes a network call to the Databricks workspace API when the sync resolution steps (config, `PGUSER`, `DATABRICKS_CLIENT_ID`) all fail. Call it once during initialization, not on every request.
0 commit comments