mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-13 15:22:30 +00:00
The TypeScript connection example only defined a helper that nothing called, so every later step failed with `db is not defined`. It now connects, as the Python one does. The Rust one kept its connection inside a helper, the Enterprise one read its settings without connecting, and the later steps relied on imports and a record-batch helper the page never showed. The quickstart now says how the steps make one program: an ES module run with Node in TypeScript, and the body of an async `main` in Rust, whose dependencies the install step lists. Each Rust step brings its own imports, the data step shows the helper that turns the records into a reader, and Arrow comes from lancedb's re-exports, so no Arrow crate is needed. The row structs no longer derive serde traits nothing used. The connection examples are shared, so the connect, create-table and branching pages gain the import line their connection code now needs.
103 lines
3.3 KiB
Plaintext
103 lines
3.3 KiB
Plaintext
---
|
|
title: "Connect to LanceDB"
|
|
sidebarTitle: "Connect"
|
|
description: "Connect to an embedded database in a local directory or in object storage, or to a LanceDB Enterprise deployment."
|
|
icon: plug
|
|
keywords: ["connect", "uri", "embedded", "object storage", "s3", "enterprise", "db://"]
|
|
---
|
|
|
|
import {
|
|
PyConnect,
|
|
PyConnectAsync,
|
|
PyConnectEnterpriseQuickstart,
|
|
PyConnectObjectStorage,
|
|
PyConnectObjectStorageAsync,
|
|
RsConnect,
|
|
TsConnect,
|
|
TsConnectEnterpriseQuickstart,
|
|
TsConnectObjectStorage,
|
|
} from '/snippets/connection.mdx';
|
|
|
|
The URI you pass to `connect` decides where the work runs. The same Python,
|
|
TypeScript and Rust SDKs open all three kinds;
|
|
[OSS and Enterprise](/basics/offerings) describes how the two offerings differ.
|
|
|
|
| URI | Where queries run |
|
|
| --- | --- |
|
|
| A local path, such as `./data` | OSS: in your process |
|
|
| `s3://`, `gs://` or `az://` | OSS: in your process, reading object storage |
|
|
| `db://` | Enterprise: on the deployment |
|
|
|
|
## A local directory {#local}
|
|
|
|
Embedded in your application, LanceDB reads and writes the tables in a
|
|
directory on disk.
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="Python (sync)" language="Python" icon="python">
|
|
{PyConnect}
|
|
</CodeBlock>
|
|
|
|
<CodeBlock filename="Python (async)" language="Python" icon="python">
|
|
{PyConnectAsync}
|
|
</CodeBlock>
|
|
|
|
<CodeBlock filename="TypeScript" language="TypeScript" icon="square-js">
|
|
{ "import * as lancedb from \"@lancedb/lancedb\";\n\n" }
|
|
{TsConnect}
|
|
</CodeBlock>
|
|
|
|
<CodeBlock filename="Rust" language="Rust" icon="rust">
|
|
{ "use lancedb::connect;\n" }
|
|
{ "\n" }
|
|
{RsConnect}
|
|
</CodeBlock>
|
|
</CodeGroup>
|
|
|
|
## Object storage {#object-storage}
|
|
|
|
With an object storage URI the library is still embedded: your process runs
|
|
every query and reads and writes the bucket directly, with the credentials from
|
|
its environment or its storage options. [Configuring storage](/deployment/storage)
|
|
covers credentials, endpoints and provider options.
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="Python (sync)" language="Python" icon="python">
|
|
{PyConnectObjectStorage}
|
|
</CodeBlock>
|
|
|
|
<CodeBlock filename="Python (async)" language="Python" icon="python">
|
|
{PyConnectObjectStorageAsync}
|
|
</CodeBlock>
|
|
|
|
<CodeBlock filename="TypeScript" language="TypeScript" icon="square-js">
|
|
{TsConnectObjectStorage}
|
|
</CodeBlock>
|
|
</CodeGroup>
|
|
|
|
In Rust, pass the same URI to `connect`.
|
|
|
|
## LanceDB Enterprise {#enterprise}
|
|
|
|
A `db://` URI connects to a deployment, which runs each operation for you. Get
|
|
the database URI, API key, region and endpoint from the deployment's
|
|
administrator. These examples read them from `LANCEDB_URI`, `LANCEDB_API_KEY`,
|
|
`LANCEDB_REGION` and `LANCEDB_HOST_OVERRIDE`, which keeps the API key out of
|
|
source, and pass the endpoint as `host_override`.
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="Python" language="Python" icon="python">
|
|
{PyConnectEnterpriseQuickstart}
|
|
</CodeBlock>
|
|
|
|
<CodeBlock filename="TypeScript" language="TypeScript" icon="square-js">
|
|
{ "import * as lancedb from \"@lancedb/lancedb\";\n\n" }
|
|
{TsConnectEnterpriseQuickstart}
|
|
</CodeBlock>
|
|
</CodeGroup>
|
|
|
|
In Rust, the connection builder takes the same settings through `api_key`,
|
|
`region` and `host_override`. To use OAuth instead of an API key, see
|
|
[Authentication](/enterprise/authentication); for every connection option, see
|
|
[Database](/management/database#deployment).
|