mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-13 15:22:30 +00:00
Move the public website pages into `docs/web` beside the SDK, with
shared navigation and executable example sources in `docs/web-tests`.
The combined website is assembled by
[lancedb/docs#355](https://github.com/lancedb/docs/pull/355), with six
Enterprise replacements from
[lancedb/sophon#7681](https://github.com/lancedb/sophon/pull/7681).
This includes Function guidance, runnable Quickstarts, regenerated
snippets, production contact/demo fixes, the legacy SQL route, and the
LeRobot redirect. LeRobot remains attributed to Geneva; all 34 Geneva
pages remain in the docs repository until Function officially launches.
Materialized-view guidance follows the full rebuild refresh introduced
by #4373: local refresh writes the complete result, has no `full`
argument, supports `source_version`, and no longer requires stable row
IDs. Deployment SQL refresh options and stable-ID setup are qualified by
version/configuration. Function input guidance distinguishes ordinary
stored columns from computed inputs supported by newer deployments.
**Validation:** independently accepted local checks include 95 Python
tests (real Enterprise excluded), eight TypeScript tests, Rust
Quickstart, snippet parity, typos, deterministic assembly, Mint
validation and links/anchors/redirects. The combined baseline retains
all 181 production routes and 17 legacy redirects. Examples ran locally
against source-built Python SDK 0.40.0b13; existing GitHub workflows do
not run `docs/web-tests`. New main at `069b2f7d` is 0.41.0b0 and adds
computed Function inputs; that SDK was not exercised by the accepted
tests. Latest prose corrections receive focused site validation.
**Merge/rollout:** merge this and #7681 before #355's combined CI, which
reads producer `main`. This is migration infrastructure: section
overlays, source-owned skills and automatic versioned paired releases
remain follow-ups. The current manual publisher is transitional. Hosted
validation, a supported SDK/Enterprise release pair and a real
Enterprise walkthrough remain pending.
Production Mintlify watches `lancedb/docs:deploy-freeze`, directory
`docs`; preserve that source through review. The separate SDK GitHub
Pages reference workflow rebuilds on main merges.
**Updated-head CI (9a50f8db):**
[Typos](https://github.com/lancedb/lancedb/actions/runs/37654185443/job/112904990558),
[PR
title](https://github.com/lancedb/lancedb/actions/runs/37654179507/job/112904974595)
and
[Aikido](https://app.aikido.dev/featurebranch/scan/215386145?groupId=74229)
pass. Critical findings in the example lockfiles were patched: all Sharp
copies use 0.35.5, protobufjs 7.6.6, tar 7.5.22, quinn-proto 0.11.19,
zerovec 0.11.8 and zerovec-derive 0.11.6. The SDK's product dependencies
are unchanged. The revised lockfiles pass eight TypeScript examples,
HuggingFace decode/resize/crop/rescale/normalize plus AVIF roundtrip,
and Rust Quickstart. Aikido passing does not mean every advisory is
cleared; npm still reports 29 high and five moderate advisories in the
example dependency graph. No scanner bypass or suppression was added.
The Function prose correction passes combined/standalone Mint,
deterministic assembly, routes and assets. The revised 325-file site
checksum is
`175bec06864abb400dd292e667ba93448c0479b8359fd7bf6146afabf9040647`. This
PR remains open for independent review; further merges are on hold.
---------
Co-authored-by: Brendan Clement <brendan.clement@lancedb.com>
194 lines
6.3 KiB
Plaintext
194 lines
6.3 KiB
Plaintext
---
|
|
title: "Database"
|
|
sidebarTitle: "Database"
|
|
description: "Connecting to LanceDB: the URI forms, their options, and what each one changes."
|
|
icon: database
|
|
keywords: ["connect", "database", "uri", "api key", "storage options", "consistency"]
|
|
---
|
|
|
|
A database is the root of a [catalog](/basics/catalog). A connection opens
|
|
exactly one, and every other object is reached through it.
|
|
|
|
Connecting is the one decision that reaches furthest: the URI you pass decides
|
|
where queries execute, which features exist, and what a table handle actually
|
|
is.
|
|
|
|
## The three URI forms {#uris}
|
|
|
|
<CodeGroup>
|
|
```python Python icon="python"
|
|
import lancedb
|
|
|
|
db = lancedb.connect("./.lancedb") # local directory
|
|
db = lancedb.connect("s3://bucket/path") # object storage
|
|
db = lancedb.connect("db://my-database", api_key="...") # a deployment
|
|
```
|
|
|
|
```typescript TypeScript icon="square-js"
|
|
import * as lancedb from "@lancedb/lancedb";
|
|
|
|
const db = await lancedb.connect("./.lancedb");
|
|
const db = await lancedb.connect("s3://bucket/path");
|
|
const db = await lancedb.connect("db://my-database", { apiKey: "..." });
|
|
```
|
|
</CodeGroup>
|
|
|
|
The first two are **embedded**: your process opens Lance tables directly from
|
|
storage and does the work itself. The third talks to a **deployment**.
|
|
|
|
| | Embedded | Deployment |
|
|
| --- | --- | --- |
|
|
| Where queries run | in your process | on the server |
|
|
| Table handle | `LanceTable` | `RemoteTable` |
|
|
| [SQL](/basics/sql) | -- | yes |
|
|
| Server-side [jobs](/basics/jobs) | -- | yes |
|
|
| [Functions](/management/function) | -- | yes |
|
|
| [Authorization](/governance/authorization) | storage permissions | granted per object |
|
|
|
|

|
|
|
|
Both handles expose the same table API -- create, open, mutate, query -- so
|
|
application code moves between them by changing the URI. What differs is where
|
|
resolution and execution happen, and therefore which operations exist at all.
|
|
|
|
## Connecting to a deployment {#deployment}
|
|
|
|
<Badge color="red">Enterprise</Badge>
|
|
|
|
<CodeGroup>
|
|
```python Python icon="python"
|
|
db = lancedb.connect(
|
|
"db://my-database",
|
|
api_key="...",
|
|
region="us-east-1",
|
|
)
|
|
```
|
|
|
|
```typescript TypeScript icon="square-js"
|
|
const db = await lancedb.connect("db://my-database", {
|
|
apiKey: "...",
|
|
region: "us-east-1",
|
|
});
|
|
```
|
|
</CodeGroup>
|
|
|
|
| Option | Meaning |
|
|
| --- | --- |
|
|
| `api_key` / `apiKey` | authenticates the connection -- see [Authentication](/enterprise/authentication) |
|
|
| `region` | which region hosts the database. Defaults to `us-east-1` |
|
|
| `host_override` / `hostOverride` | point at a specific endpoint instead of the regional one |
|
|
| `sql_host_override` | the same, for the [SQL endpoint](/sql#connecting). Python only |
|
|
| `client_config` / `clientConfig` | retries, timeouts, and connection pooling |
|
|
|
|
An API key belongs in the environment, not in source. `region` is easy to get
|
|
wrong silently -- the default is `us-east-1` whether or not that is where your
|
|
database lives, and a wrong region fails as a connection error rather than a
|
|
helpful one.
|
|
|
|
## Storage options {#storage-options}
|
|
|
|
`storage_options` configures the underlying object store -- credentials,
|
|
endpoints, and defaults for tables created through this connection:
|
|
|
|
<CodeGroup>
|
|
```python Python icon="python"
|
|
db = lancedb.connect(
|
|
"s3://bucket/path",
|
|
storage_options={"new_table_enable_stable_row_ids": "true"},
|
|
)
|
|
```
|
|
|
|
```typescript TypeScript icon="square-js"
|
|
const db = await lancedb.connect("s3://bucket/path", {
|
|
storageOptions: { new_table_enable_stable_row_ids: "true" },
|
|
});
|
|
```
|
|
</CodeGroup>
|
|
|
|
<Warning>
|
|
`new_table_enable_stable_row_ids` is worth setting deliberately: it gives stable
|
|
row ids to the tables this connection creates, and no SDK call adds them to an
|
|
existing table. A `db://` connection does not send it; a deployment decides
|
|
stable row ids itself (see
|
|
[Against a deployment](/feature-engineering/materialized-views#availability)).
|
|
</Warning>
|
|
|
|
See [Storage](/deployment/storage) for the full set, including per-cloud credentials.
|
|
|
|
## Read consistency {#consistency}
|
|
|
|
`read_consistency_interval` controls how often a connection checks for versions
|
|
committed by other writers.
|
|
|
|
<CodeGroup>
|
|
```python Python icon="python"
|
|
from datetime import timedelta
|
|
|
|
db = lancedb.connect(uri, read_consistency_interval=timedelta(seconds=5))
|
|
```
|
|
|
|
```typescript TypeScript icon="square-js"
|
|
const db = await lancedb.connect(uri, { readConsistencyInterval: 5 });
|
|
```
|
|
</CodeGroup>
|
|
|
|
The default reads a snapshot taken when the table was opened, so a long-lived
|
|
connection **will not see other processes' writes** until it reopens the table.
|
|
That is the right default for a batch job and the wrong one for a service.
|
|
|
|
Set it when several processes write the same table and readers must observe
|
|
those writes. The cost is a metadata check on that interval. See
|
|
[Consistency](/tables/consistency).
|
|
|
|
## Database-level operations {#operations}
|
|
|
|
| | Python | TypeScript | SQL |
|
|
| --- | --- | --- | --- |
|
|
| list tables | `table_names`, `list_tables` | `tableNames`, `listTables` | -- |
|
|
| the URI it opened | `uri` | `display()` | -- |
|
|
| drop every table | `drop_all_tables` | `dropAllTables` | -- |
|
|
| drop the database | `drop_database` | -- | -- |
|
|
| close | -- | `close`, `isOpen` | -- |
|
|
|
|
<CodeGroup>
|
|
```python Python icon="python"
|
|
db.table_names()
|
|
tbl = db.open_table("documents")
|
|
db.drop_table("documents")
|
|
```
|
|
|
|
```typescript TypeScript icon="square-js"
|
|
await db.tableNames();
|
|
const tbl = await db.openTable("documents");
|
|
await db.dropTable("documents");
|
|
```
|
|
|
|
```sql SQL
|
|
DROP TABLE documents;
|
|
```
|
|
</CodeGroup>
|
|
|
|
Each takes a `namespace_path` to act inside a [namespace](/management/namespace) rather
|
|
than at the root.
|
|
|
|
<Warning>
|
|
`drop_database()` removes every table in the database. There is no confirmation
|
|
and no undo -- table [versioning](/management/table#versioning) does not survive the table
|
|
being dropped.
|
|
</Warning>
|
|
|
|
## Async connections {#async}
|
|
|
|
`connect_async` returns an `AsyncConnection` with the same surface as
|
|
coroutines. The TypeScript SDK is async throughout, so its `connect` already is
|
|
one.
|
|
|
|
```python
|
|
db = await lancedb.connect_async("db://my-database", api_key="...")
|
|
tbl = await db.open_table("documents")
|
|
```
|
|
|
|
This is a different axis from the `_async` operations that return a
|
|
[job](/basics/jobs): `connect_async` is about not blocking your event loop,
|
|
while `create_index_async` is about work that outlives the call.
|