@lancedb/lancedb • Docs
@lancedb/lancedb / connectNamespace
Function: connectNamespace()¶
connectNamespace(implName, config, options)¶
Connect to a LanceDB database through a namespace.
Unlike connect, which routes by URI scheme (local path vs.
db:// cloud), connectNamespace always returns a namespace-backed
connection. The implName selects the namespace implementation:
"dir"— directory namespace, configured with DirNamespaceConfig."rest"— remote REST catalog, configured with RestNamespaceConfig.- Any other string — full module path for a custom implementation,
configured with a free-form string-keyed
propertiesmap.
Parameters¶
-
implName:
"dir" -
config:
DirNamespaceConfig -
options?:
Partial<ConnectNamespaceOptions>
Returns¶
Promise<Connection>
Examples¶
const db = await connectNamespace("dir", { root: "/path/to/db" });
await db.createTable("users", [{ id: 1 }]);
const db = await connectNamespace("rest", {
uri: "https://catalog.example.com",
headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
});
connectNamespace(implName, config, options)¶
Connect through the built-in REST namespace.
Configured with RestNamespaceConfig. See the function-level documentation above for the full surface, examples, and how this relates to connect.
Parameters¶
-
implName:
"rest" -
config:
RestNamespaceConfig -
options?:
Partial<ConnectNamespaceOptions>
Returns¶
Promise<Connection>
Example¶
const db = await connectNamespace("rest", {
uri: "https://catalog.example.com",
headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
});
connectNamespace(implName, properties, options)¶
Connect through a custom namespace implementation by full module path,
configured with a free-form string-keyed properties map. Use the
typed overloads above for the built-in "dir" and "rest" impls.
See the function-level documentation above for examples and how this relates to connect.
Parameters¶
-
implName:
string -
properties:
Record<string,string> -
options?:
Partial<ConnectNamespaceOptions>
Returns¶
Promise<Connection>