docs: read Enterprise connection settings from the shared variables

The Enterprise connection examples now read the database URI from
LANCEDB_URI and the endpoint from LANCEDB_HOST_OVERRIDE, with the API
key and region beside them, the convention the rest of the site uses.
Without an endpoint they stop rather than fall back to one. Their tests
check both.

The REST API reference used LANCEDB_URI for the HTTP endpoint and listed
and created tables at routes the server does not serve. It now uses
LANCEDB_HOST_OVERRIDE, lists tables at /v1/table/, creates `words` from
an Arrow IPC stream, and describes it to confirm the write.
This commit is contained in:
Brendan Clement
2026-10-09 13:27:41 -07:00
parent a15ca4dda4
commit 08793c7617
7 changed files with 103 additions and 65 deletions
+18 -8
View File
@@ -35,10 +35,13 @@ To authenticate to the Enterprise REST API, you need the endpoint for your deplo
```bash
export LANCEDB_API_KEY="<your-api-key>"
export LANCEDB_URI="https://your-enterprise-endpoint.com"
export LANCEDB_HOST_OVERRIDE="https://your-enterprise-endpoint.com"
export LANCEDB_DATABASE="your-database-name"
```
`LANCEDB_HOST_OVERRIDE` is the endpoint the SDKs take as `host_override`; the
database name is the part of its `db://` URI after `db://`.
3. If your Enterprise deployment is private, connect through the private network endpoint provided for your deployment. For example, Azure Private Link deployments commonly use a private IP or an internal DNS name as the endpoint.
### Verify authentication {#verify-authentication}
@@ -46,30 +49,37 @@ export LANCEDB_DATABASE="your-database-name"
4. Check that you can reach the deployment and list tables:
```bash
curl -X GET "$LANCEDB_URI/v1/management/table" \
-H "Content-Type: application/json" \
curl -X GET "$LANCEDB_HOST_OVERRIDE/v1/table/" \
-H "x-api-key: $LANCEDB_API_KEY" \
-H "x-lancedb-database: $LANCEDB_DATABASE"
```
The response lists one page of table names, with a token for the next page when
there are more.
If your deployment endpoint already includes the database host name, you can omit the `x-lancedb-database` header.
5. Create a table to confirm write access. Let's call it `words`.
5. Create a table to confirm write access. Let's call it `words`. A table is
created from an Arrow IPC stream, which this writes with PyArrow:
```bash
curl -X POST "$LANCEDB_URI/v1/tables/words" \
python -c "import pyarrow as pa, sys; t = pa.table({'word': ['hello', 'world']}); w = pa.ipc.new_stream(sys.stdout.buffer, t.schema); w.write_table(t); w.close()" > words.arrow
curl -X POST "$LANCEDB_HOST_OVERRIDE/v1/table/words/create" \
-H "Content-Type: application/vnd.apache.arrow.stream" \
-H "x-api-key: $LANCEDB_API_KEY" \
-H "x-lancedb-database: $LANCEDB_DATABASE"
-H "x-lancedb-database: $LANCEDB_DATABASE" \
--data-binary @words.arrow
```
6. Check that the table has been created:
```bash
curl -X GET "$LANCEDB_URI/v1/management/table" \
curl -X POST "$LANCEDB_HOST_OVERRIDE/v1/table/words/describe" \
-H "Content-Type: application/json" \
-H "x-api-key: $LANCEDB_API_KEY" \
-H "x-lancedb-database: $LANCEDB_DATABASE"
-H "x-lancedb-database: $LANCEDB_DATABASE" \
-d '{}'
```
That's it -- you're connected! Now, you can start adding data and querying it.
+3 -3
View File
@@ -80,12 +80,12 @@ In Rust, pass the same URI to `connect`.
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, and pass the endpoint as `host_override`. Keep the API key in a
secret manager or the environment rather than in source.
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">
{ "import lancedb\n\n" }
{PyConnectEnterpriseQuickstart}
</CodeBlock>
+3 -4
View File
@@ -184,12 +184,12 @@ For credentials, endpoints, and provider-specific options, see
If you're using LanceDB Enterprise, you can connect to the remote database using the
`db://` URI along with the API key, region, and cluster endpoint you received from the
LanceDB team. Pass the cluster endpoint via `host_override` so the client routes
requests to your deployment.
LanceDB team. These examples read them from `LANCEDB_URI`, `LANCEDB_API_KEY`,
`LANCEDB_REGION` and `LANCEDB_HOST_OVERRIDE`, and pass the cluster endpoint via
`host_override` so the client routes requests to your deployment.
<CodeGroup >
<CodeBlock filename="Python" language="Python" icon="python">
{ "import lancedb\n\n" }
{PyConnectEnterpriseQuickstart}
</CodeBlock>
@@ -199,7 +199,6 @@ requests to your deployment.
</CodeBlock>
<CodeBlock filename="Rust" language="Rust" icon="rust">
{ "use lancedb::connect;\n\n" }
{RsConnectEnterpriseQuickstart}
</CodeBlock>
</CodeGroup >
+3 -3
View File
@@ -4,7 +4,7 @@ export const PyConnect = "import lancedb\n\nuri = \"ex_lancedb\"\ndb = lancedb.c
export const PyConnectAsync = "import lancedb\n\nuri = \"ex_lancedb\"\nasync_db = await lancedb.connect_async(uri)\n";
export const PyConnectEnterpriseQuickstart = "uri = \"db://your-database-uri\"\napi_key = \"your-api-key\"\nregion = \"us-east-1\"\nhost_override = \"https://your-enterprise-endpoint.com\"\n\ndb = lancedb.connect(\n uri=uri,\n api_key=api_key,\n region=region,\n host_override=host_override,\n)\n";
export const PyConnectEnterpriseQuickstart = "import os\n\nimport lancedb\n\ndb = lancedb.connect(\n uri=os.environ[\"LANCEDB_URI\"], # db://your-database\n api_key=os.environ[\"LANCEDB_API_KEY\"],\n region=os.environ.get(\"LANCEDB_REGION\", \"us-east-1\"),\n host_override=os.environ[\"LANCEDB_HOST_OVERRIDE\"], # https://your-endpoint\n)\n";
export const PyConnectObjectStorage = "import lancedb\n\nuri = \"s3://your-bucket/path\"\n# You can also use \"gs://your-bucket/path\" or \"az://your-container/path\".\ndb = lancedb.connect(uri)\n";
@@ -16,7 +16,7 @@ export const PyNamespaceTableOps = "import lancedb\n\ndb = lancedb.connect_names
export const TsConnect = "import * as lancedb from \"@lancedb/lancedb\";\n\nasync function connectExample(uri: string) {\n const db = await lancedb.connect(uri);\n return db;\n}\n";
export const TsConnectEnterpriseQuickstart = "const uri = \"db://your-database-uri\";\nconst apiKey = \"your-api-key\";\nconst region = \"us-east-1\";\nconst hostOverride = \"https://your-enterprise-endpoint.com\";\n\nconst db = await lancedb.connect(uri, {\n apiKey,\n region,\n hostOverride,\n});\n";
export const TsConnectEnterpriseQuickstart = "const setting = (name: string) => {\n const value = process.env[name];\n if (!value) throw new Error(`Set ${name}`);\n return value;\n};\n\nconst db = await lancedb.connect(setting(\"LANCEDB_URI\"), {\n apiKey: setting(\"LANCEDB_API_KEY\"),\n region: process.env.LANCEDB_REGION ?? \"us-east-1\",\n hostOverride: setting(\"LANCEDB_HOST_OVERRIDE\"),\n});\n";
export const TsConnectObjectStorage = "async function connectObjectStorageExample() {\n const uri = \"s3://your-bucket/path\";\n // You can also use \"gs://your-bucket/path\" or \"az://your-container/path\".\n const db = await lancedb.connect(uri);\n return db;\n}\n";
@@ -26,7 +26,7 @@ export const TsNamespaceTableOps = "const db = await lancedb.connectNamespace(\"
export const RsConnect = "async fn connect_example(uri: &str) {\n let db = connect(uri).execute().await.unwrap();\n let _ = db;\n}\n";
export const RsConnectEnterpriseQuickstart = "let uri = \"db://your-database-uri\";\nlet api_key = \"your-api-key\";\nlet region = \"us-east-1\";\nlet host_override = \"https://your-enterprise-endpoint.com\";\n";
export const RsConnectEnterpriseQuickstart = "let uri = std::env::var(\"LANCEDB_URI\")?; // db://your-database\nlet api_key = std::env::var(\"LANCEDB_API_KEY\")?;\nlet region = std::env::var(\"LANCEDB_REGION\").unwrap_or_else(|_| \"us-east-1\".to_string());\nlet host_override = std::env::var(\"LANCEDB_HOST_OVERRIDE\")?; // https://your-endpoint\n";
export const RsConnectObjectStorage = "let uri = \"s3://your-bucket/path\";\n// You can also use \"gs://your-bucket/path\" or \"az://your-container/path\".\n";