Connections
- group Connections
Connect to embedded, namespace, and remote databases.
Enums
-
enum LanceDBClientConfigField
Client configuration fields of LanceDBClientConfig.
Every bit makes the matching scalar an override. A field whose bit is not set keeps the SDK value, so an omitted timeout or retry budget stays distinct from an explicit zero. Strings use NULL for “unset”, so an empty non-NULL string remains an explicit empty value.
Values:
-
enumerator LANCEDB_CLIENT_CONFIG_TIMEOUT
-
enumerator LANCEDB_CLIENT_CONFIG_CONNECT_TIMEOUT
-
enumerator LANCEDB_CLIENT_CONFIG_READ_TIMEOUT
-
enumerator LANCEDB_CLIENT_CONFIG_POOL_IDLE_TIMEOUT
-
enumerator LANCEDB_CLIENT_CONFIG_RETRIES
-
enumerator LANCEDB_CLIENT_CONFIG_CONNECT_RETRIES
-
enumerator LANCEDB_CLIENT_CONFIG_READ_RETRIES
-
enumerator LANCEDB_CLIENT_CONFIG_BACKOFF_FACTOR
-
enumerator LANCEDB_CLIENT_CONFIG_BACKOFF_JITTER
-
enumerator LANCEDB_CLIENT_CONFIG_RETRY_STATUSES
-
enumerator LANCEDB_CLIENT_CONFIG_BLOB_REQUEST_CONCURRENCY
-
enumerator LANCEDB_CLIENT_CONFIG_MAX_BYTES_PER_REQUEST
-
enumerator LANCEDB_CLIENT_CONFIG_MAX_REQUEST_DURATION
-
enumerator LANCEDB_CLIENT_CONFIG_TLS_ASSERT_HOSTNAME
-
enumerator LANCEDB_CLIENT_CONFIG_TIMEOUT
-
enum LanceDBNamespacePushdownOperation
Namespace operations that can be pushed down to the namespace backend.
These values are the SDK’s complete set of pushdown operations. They are explicit so a C caller can pass and be rejected for any other value.
Values:
-
enumerator LANCEDB_NAMESPACE_PUSHDOWN_QUERY_TABLE
-
enumerator LANCEDB_NAMESPACE_PUSHDOWN_CREATE_TABLE
-
enumerator LANCEDB_NAMESPACE_PUSHDOWN_QUERY_TABLE
-
enum LanceDBOpenTableField
Open table option fields of LanceDBOpenTableOptions.
Every bit makes the matching field an override. A field whose bit is not set keeps the LanceDB default, so an omitted index cache size stays distinct from an explicit zero, and an omitted managed-versioning value stays distinct from an explicit false.
Values:
-
enumerator LANCEDB_OPEN_TABLE_INDEX_CACHE_SIZE
-
enumerator LANCEDB_OPEN_TABLE_VERSION
-
enumerator LANCEDB_OPEN_TABLE_MANAGED_VERSIONING
-
enumerator LANCEDB_OPEN_TABLE_INDEX_CACHE_SIZE
Functions
-
LanceDBConnectBuilder *lancedb_connect(const char *uri)
Create a ConnectBuilder for the given URI.
The URI can be:
”/path/to/database” - local database on file system
”s3://bucket/path/to/database” or “gs://bucket/path/to/database” - database on cloud object store
”db://dbname” - LanceDB Cloud
The returned pointer must be freed with lancedb_connect_builder_free().
- Parameters:
uri – - null-terminated C string containing the database URI
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
LanceDBError lancedb_connect_builder_execute(LanceDBConnectBuilder *builder, LanceDBConnection **connection, char **error_message)
Execute the connection and return a Connection handle.
A non-NULL builder is consumed on every path and must not be used after calling. connection is written only on success, when it receives a handle that must be freed with lancedb_connection_free(); on failure a non-NULL connection slot is left unchanged. An existing *error_message value is preserved on success, consistent with lancedb_connect_namespace_builder_execute(). On error, a non-NULL error_message receives a message that the caller frees with lancedb_free_string().
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
connection – - pointer to receive the LanceDBConnection pointer
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBConnectBuilder *lancedb_connect_builder_storage_option(LanceDBConnectBuilder *builder, const char *key, const char *value)
Set an option for the storage layer.
The builder is consumed by this function and must not be used after calling.
The key and value are going through basic validation at this point, and error will happen when trying to execute a builder with unsupported key or value.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
key – - null-terminated C string containing the name of the option
value – - null-terminated C string containing the value of the option
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
LanceDBConnectBuilder *lancedb_connect_builder_api_key(LanceDBConnectBuilder *builder, const char *api_key)
Set the API key for a LanceDB Enterprise or LanceDB Cloud connection.
The builder is consumed by this function and must not be used after calling. The value is only applied when the connection dispatches to the SDK remote path, which is selected by a URI beginning with db. The setter does not add it to native storage options. Without the remote feature, the setter validates and returns the builder without applying the value. A NULL or non-UTF-8 api_key returns NULL.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
api_key – - NUL-terminated API key
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
LanceDBConnectBuilder *lancedb_connect_builder_region(LanceDBConnectBuilder *builder, const char *region)
Set the region for a db:// connection.
The builder is consumed by this function and must not be used after calling. The SDK requires a region for both LanceDB Cloud and LanceDB Enterprise connections, including when a host override is used. This setter is only applied when the connection dispatches to the SDK remote path, which is selected by a URI beginning with db. Without the remote feature, the setter validates and returns the builder without applying the value. A NULL or non-UTF-8 region returns NULL.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
region – - NUL-terminated region name
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
LanceDBConnectBuilder *lancedb_connect_builder_host_override(LanceDBConnectBuilder *builder, const char *host_override)
Set the host override for a LanceDB Enterprise connection.
The builder is consumed by this function and must not be used after calling. The value is only applied when the connection dispatches to the SDK remote path, which is selected by a URI beginning with db. Use the URI db:// together with a host override to connect to LanceDB Enterprise tables stored directly in the storage root. Without the remote feature, the setter validates and returns the builder without applying the value. A NULL or non-UTF-8 host_override returns NULL.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
host_override – - NUL-terminated host override
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
LanceDBConnectBuilder *lancedb_connect_builder_sql_host_override(LanceDBConnectBuilder *builder, const char *sql_host_override)
Set the SQL service host override for a LanceDB Enterprise connection.
The builder is consumed by this function and must not be used after calling. The value is only applied when the connection dispatches to the SDK remote path, which is selected by a URI beginning with db. The SQL endpoint is contacted only when the connection executes SQL; setting this option does not contact it. Without the remote feature, the setter validates and returns the builder without applying the value. A NULL or non-UTF-8 sql_host_override returns NULL.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
sql_host_override – - NUL-terminated SQL host override
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
LanceDBConnectBuilder *lancedb_connect_builder_namespace_client_property(LanceDBConnectBuilder *builder, const char *key, const char *value)
Set an additional property for the connection’s namespace client.
The builder is consumed by this function and must not be used after calling. A NULL or non-UTF-8 key or value returns NULL. LanceDB Enterprise connections reject a non-empty set of namespace client properties when the builder is executed: lancedb_connect_builder_execute() returns LANCEDB_NOT_SUPPORTED.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
key – - NUL-terminated property name
value – - NUL-terminated property value
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
LanceDBConnectBuilder *lancedb_connect_builder_manifest_enabled(LanceDBConnectBuilder *builder, bool enabled)
Enable or disable manifest-backed directory namespace mode.
The builder is consumed by this function and must not be used after calling. This option applies to local native connections. When enabled, the connection uses the directory namespace directly for all table operations and forces dir_listing_to_manifest_migration_enabled=true. LanceDB Enterprise connections reject enabling this option when the builder is executed: lancedb_connect_builder_execute() returns LANCEDB_NOT_SUPPORTED. Passing false keeps the default behavior.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
enabled – - true to enable manifest-backed directory namespace mode
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
LanceDBConnectBuilder *lancedb_connect_builder_read_consistency_interval_ms(LanceDBConnectBuilder *builder, uint64_t interval_ms)
Set the read consistency interval.
The builder is consumed by this function and must not be used after calling. Leaving this setter unused keeps the SDK default: no freshness constraint is added to reads. An explicit 0 requests strong consistency. A positive value requests eventual consistency. The interval only affects reads; writes are always consistent.
Native connections use the interval as a refresh target: the SDK may refresh in the background before it expires and refreshes synchronously on the next read after it. Remote latest-timeline requests send the interval as a per-request minimum freshness bound; pinned snapshots omit that freshness routing header. Reading the configured mode back through lancedb_connection_read_consistency() is supported for native connections; the SDK reports LANCEDB_NOT_SUPPORTED for remote connections.
A NULL builder returns NULL.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
interval_ms – - read consistency interval in milliseconds
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
LanceDBConnectBuilder *lancedb_connect_builder_session(LanceDBConnectBuilder *builder, const LanceDBSession *session)
Set session for the connection builder.
The builder is consumed by this function and must not be used after calling. Passing NULL session is a no-op.
A custom session is only supported for embedded connections. LanceDB Enterprise connections (db:// URIs) reject it when the builder is executed: lancedb_connect_builder_execute() returns LANCEDB_NOT_SUPPORTED with an error message stating that session is not supported for LanceDB Enterprise connections.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
session – - pointer to LanceDBSession, or NULL to keep current/default session behavior
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
LanceDBConnectBuilder *lancedb_connect_builder_client_config(LanceDBConnectBuilder *builder, const LanceDBClientConfig *config)
Set the HTTP client configuration for a remote connection.
The builder is consumed by this function and must not be used after calling. A successful call replaces the builder’s ClientConfig; it does not merge with an earlier call. The configuration only reaches connections dispatched to the SDK remote path. Native connections keep the builder unchanged. The SDK validates the configuration when the builder is executed.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
config – - pointer to read-only configuration, or NULL for every SDK default
- Returns:
Non-null pointer to LanceDBConnectBuilder on success, NULL on failure
-
void lancedb_connect_builder_free(LanceDBConnectBuilder *builder)
Free a ConnectBuilder.
After calling this function, the builder pointer must not be used.
- Parameters:
builder – - pointer to LanceDBConnectBuilder returned from lancedb_connect()
-
LanceDBConnectNamespaceBuilder *lancedb_connect_namespace(const char *ns_impl, const char *const *property_keys, const char *const *property_values, size_t property_count)
Create a ConnectNamespaceBuilder for a Lance namespace implementation.
“dir” is always available and requires a “root” property. “rest” is available only when the library is built with the remote feature. The pinned SDK rejects any other implementation when the builder is executed. Other properties, their defaults, and required values are defined by the selected namespace implementation.
The implementation name, property arrays, and every string they point to are borrowed only for the duration of this call and copied into the returned builder. A zero property_count accepts NULL arrays. A positive count requires both arrays and every entry to be non-NULL, NUL-terminated UTF-8 strings.
For the “dir” implementation, properties whose names start with “storage.” apply to its own root object store. This is separate from the connection storage-options map set by lancedb_connect_namespace_builder_storage_option().
The returned builder must be freed with lancedb_connect_namespace_builder_free() if it is not executed.
- Parameters:
ns_impl – - NUL-terminated namespace implementation name
property_keys – - array of property names (NULL when property_count is 0)
property_values – - array of property values matching property_keys
property_count – - number of namespace implementation properties
- Returns:
Non-null pointer to LanceDBConnectNamespaceBuilder on success, NULL on failure
-
LanceDBError lancedb_connect_namespace_builder_execute(LanceDBConnectNamespaceBuilder *builder, LanceDBConnection **connection, char **error_message)
Execute the namespace connection and return a Connection handle.
The builder is consumed on every path and must not be used after calling. connection is written only on success, when it receives a handle that must be freed with lancedb_connection_free(); on failure it is left unchanged. An existing *error_message value is preserved on success, consistent with lancedb_connect_builder_execute(). On error, a non-NULL error_message receives a message that the caller frees with lancedb_free_string().
The SDK decides whether the implementation exists in this build, validates the implementation properties, and performs the connection. The URI of the returned connection is “namespace://<implementation>”.
- Parameters:
builder – - pointer to LanceDBConnectNamespaceBuilder returned from lancedb_connect_namespace()
connection – - pointer to receive the LanceDBConnection pointer
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBConnectNamespaceBuilder *lancedb_connect_namespace_builder_storage_option(LanceDBConnectNamespaceBuilder *builder, const char *key, const char *value)
Set an option for the storage layer of a namespace connection.
The builder is consumed by this function and must not be used after calling. A NULL or non-UTF-8 key or value returns NULL. These options apply to table access through the namespace connection. They are not the “storage.*” implementation properties that the “dir” namespace uses for its own root object store.
At the pinned SDK, the table creation path falls back to this map only when the namespace response omits storage_options. An explicit empty storage_options map prevents that fallback. The selected map overrides per-write keys with the same name.
Opening a table uses the describe_table storage options plus the options supplied on that open request, with namespace values winning on overlaps; it does not use this connection-level map there.
The SDK does not validate every option during the namespace connection itself.
- Parameters:
builder – - pointer to LanceDBConnectNamespaceBuilder returned from lancedb_connect_namespace()
key – - NUL-terminated option name
value – - NUL-terminated option value
- Returns:
Non-null pointer to LanceDBConnectNamespaceBuilder on success, NULL on failure
-
LanceDBConnectNamespaceBuilder *lancedb_connect_namespace_builder_namespace_client_property(LanceDBConnectNamespaceBuilder *builder, const char *key, const char *value)
Set an additional property for the namespace client.
The builder is consumed by this function and must not be used after calling. A NULL or non-UTF-8 key or value returns NULL.
Namespace client properties are merged into the implementation properties when the builder is executed. The SDK decides which value wins when the same key is supplied as an implementation property and as a namespace client property. For the “dir” implementation, a property whose name starts with “storage.” configures its own root object store even when it is supplied through this setter; this differs from lancedb_connect_namespace_builder_storage_option(), which configures table access for the connection.
- Parameters:
builder – - pointer to LanceDBConnectNamespaceBuilder returned from lancedb_connect_namespace()
key – - NUL-terminated property name
value – - NUL-terminated property value
- Returns:
Non-null pointer to LanceDBConnectNamespaceBuilder on success, NULL on failure
-
LanceDBConnectNamespaceBuilder *lancedb_connect_namespace_builder_read_consistency_interval_ms(LanceDBConnectNamespaceBuilder *builder, uint64_t interval_ms)
Set the read consistency interval for a namespace connection.
The builder is consumed by this function and must not be used after calling. Leaving this setter unused keeps the SDK default: no freshness constraint is added to reads. An explicit 0 requests strong consistency. A positive value requests eventual consistency. A NULL builder returns NULL.
This has the same meaning and defaults as lancedb_connect_builder_read_consistency_interval_ms() for a URI connection. The configured mode can be read back with lancedb_connection_read_consistency().
- Parameters:
builder – - pointer to LanceDBConnectNamespaceBuilder returned from lancedb_connect_namespace()
interval_ms – - read consistency interval in milliseconds
- Returns:
Non-null pointer to LanceDBConnectNamespaceBuilder on success, NULL on failure
-
LanceDBConnectNamespaceBuilder *lancedb_connect_namespace_builder_session(LanceDBConnectNamespaceBuilder *builder, const LanceDBSession *session)
Set a session for the namespace connection builder.
The builder is consumed by this function and must not be used after calling. Passing NULL session is a no-op. A non-NULL session is borrowed for the call; the builder keeps it alive through a cloned reference, and the caller still owns its handle and must free it with lancedb_session_free().
- Parameters:
builder – - pointer to LanceDBConnectNamespaceBuilder returned from lancedb_connect_namespace()
session – - pointer to LanceDBSession, or NULL to keep the default session
- Returns:
Non-null pointer to LanceDBConnectNamespaceBuilder on success, NULL on failure
-
LanceDBConnectNamespaceBuilder *lancedb_connect_namespace_builder_pushdown_operation(LanceDBConnectNamespaceBuilder *builder, int operation)
Add an operation to push down to the namespace backend.
The builder is consumed by this function and must not be used after calling. Operations are opt-in; unset means the SDK executes them locally. Call this setter more than once to add multiple operations. A value outside the LanceDBNamespacePushdownOperation enumerators returns NULL.
With LANCEDB_NAMESPACE_PUSHDOWN_QUERY_TABLE, queries execute through the namespace server; a query with a nonempty order_by still executes locally and needs client access to table storage. LANCEDB_NAMESPACE_PUSHDOWN_CREATE_TABLE is the SDK’s other pushdown value; at the pinned SDK version the namespace create path still declares the table and writes locally, so this option is forwarded without changing that path. The SDK owns whether and how an implementation applies either operation.
- Parameters:
builder – - pointer to LanceDBConnectNamespaceBuilder returned from lancedb_connect_namespace()
operation – - raw integer value of a LanceDBNamespacePushdownOperation enumerator
- Returns:
Non-null pointer to LanceDBConnectNamespaceBuilder on success, NULL on failure
-
void lancedb_connect_namespace_builder_free(LanceDBConnectNamespaceBuilder *builder)
Free a ConnectNamespaceBuilder.
After calling this function, the builder pointer must not be used.
- Parameters:
builder – - pointer to LanceDBConnectNamespaceBuilder returned from lancedb_connect_namespace()
-
const char *lancedb_connection_uri(const LanceDBConnection *connection)
Get the URI of the connection.
The returned string is valid until the connection is freed. The caller must not free the returned string.
- Parameters:
connection – - pointer to LanceDBConnection
- Returns:
Pointer to null-terminated C string containing the URI, or NULL on failure
-
LanceDBError lancedb_connection_read_consistency(const LanceDBConnection *connection, LanceDBReadConsistency *consistency_out, char **error_message)
Get the read consistency of the connection.
On success, consistency_out describes the configured mode. A connection created without lancedb_connect_builder_read_consistency_interval_ms() reports LANCEDB_READ_CONSISTENCY_MANUAL. An explicit zero interval reports LANCEDB_READ_CONSISTENCY_STRONG. A positive interval reports LANCEDB_READ_CONSISTENCY_EVENTUAL with interval_ms set to that value.
On failure, consistency_out is left unchanged so a caller can keep its own sentinel there. LanceDB Enterprise and LanceDB Cloud connections return LANCEDB_NOT_SUPPORTED because the SDK does not expose their read consistency, even though the interval still controls their per-request freshness bound. A non-NULL error_message is cleared on entry and must be freed with lancedb_free_string() after an error.
This function does not fall back to a predicted mode when the SDK query fails.
- Parameters:
connection – - pointer to LanceDBConnection
consistency_out – - pointer to receive the read consistency
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_table_names(const LanceDBConnection *connection, char ***names_out, size_t *count_out, char **error_message)
Get table names from the connection.
The caller is responsible for freeing the returned strings and array using lancedb_free_table_names(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
names_out – - pointer to receive array of string pointers
count_out – - pointer to receive count of table names
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
void lancedb_free_table_names(char **names, size_t count)
Free table names array returned by lancedb_connection_table_names.
- Parameters:
names – - array of string pointers returned by lancedb_connection_table_names
count – - number of strings in the array
-
LanceDBTableNamesBuilder *lancedb_connection_table_names_builder(const LanceDBConnection *connection)
Create a TableNamesBuilder for paginated table listing.
The returned pointer must be freed with lancedb_table_names_builder_free(). Use lancedb_table_names_builder_limit() and lancedb_table_names_builder_start_after() to configure pagination before calling lancedb_table_names_builder_execute().
- Parameters:
connection – - pointer to LanceDBConnection
- Returns:
Non-null pointer to LanceDBTableNamesBuilder on success, NULL on failure
-
LanceDBTableNamesBuilder *lancedb_table_names_builder_limit(LanceDBTableNamesBuilder *builder, unsigned int limit)
Set limit on TableNamesBuilder.
The builder is consumed by this function and must not be used after calling.
- Parameters:
builder – - pointer to LanceDBTableNamesBuilder
limit – - maximum number of table names to return
- Returns:
Non-null pointer to LanceDBTableNamesBuilder on success, NULL on failure
-
LanceDBTableNamesBuilder *lancedb_table_names_builder_start_after(LanceDBTableNamesBuilder *builder, const char *start_after)
Set start_after on TableNamesBuilder for pagination.
The builder is consumed by this function and must not be used after calling. This is used for pagination - returns table names alphabetically after the specified name.
- Parameters:
builder – - pointer to LanceDBTableNamesBuilder
start_after – - null-terminated C string containing the table name to start after
- Returns:
Non-null pointer to LanceDBTableNamesBuilder on success, NULL on failure
-
LanceDBTableNamesBuilder *lancedb_table_names_builder_namespace(LanceDBTableNamesBuilder *builder, const char *const *namespace_path, size_t namespace_path_len)
Set the namespace path on TableNamesBuilder.
The builder is consumed by this function and must not be used after calling. A zero length selects the root namespace. A positive length requires a non-NULL array whose entries are non-NULL, NUL-terminated UTF-8 strings.
- Parameters:
builder – - pointer to LanceDBTableNamesBuilder
namespace_path – - array of namespace component strings (NULL when namespace_path_len is 0)
namespace_path_len – - number of namespace components (0 for the root namespace)
- Returns:
Non-null pointer to LanceDBTableNamesBuilder on success, NULL on invalid input
-
LanceDBError lancedb_table_names_builder_execute(LanceDBTableNamesBuilder *builder, char ***names_out, size_t *count_out, char **error_message)
Execute TableNamesBuilder and return table names.
The builder is consumed by this function and must not be used after calling. The caller is responsible for freeing the returned strings and array using lancedb_free_table_names(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
builder – - pointer to LanceDBTableNamesBuilder (consumed by this function)
names_out – - pointer to receive array of string pointers
count_out – - pointer to receive count of table names
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
void lancedb_table_names_builder_free(LanceDBTableNamesBuilder *builder)
Free a TableNamesBuilder.
After calling this function, the builder pointer must not be used.
- Parameters:
builder – - pointer to LanceDBTableNamesBuilder
-
LanceDBError lancedb_connection_open_table(const LanceDBConnection *connection, const char *table_name, LanceDBTable **table_out, char **error_message)
Open an existing table.
On success, the table returned in table_out must be freed with lancedb_table_free(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
table_name – - null-terminated C string containing the table name
table_out – - pointer to receive the opened table
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure.
-
LanceDBError lancedb_connection_open_table_with_options(const LanceDBConnection *connection, const char *table_name, const LanceDBOpenTableOptions *options, LanceDBTable **table_out, char **error_message)
Open an existing table with SDK open-table builder options.
On entry, a non-NULL table_out is set to NULL and the error message slot is cleared. The table is written only on success, so a failure leaves it NULL. This differs from lancedb_connection_open_table, which leaves its output unchanged on failure. The caller frees a returned table with lancedb_table_free() and a returned error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
table_name – - null-terminated C string containing the table name
options – - pointer to read-only options, or NULL for every SDK default
table_out – - pointer to receive the opened table
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_clone_table(const LanceDBConnection *connection, const char *target_table_name, const char *source_uri, const LanceDBCloneTableOptions *options, LanceDBTable **table_out, char **error_message)
Clone a table from an existing source table.
On entry, a non-NULL table_out is set to NULL and a non-NULL error_message is cleared. On success, table_out receives a handle that the caller must free with lancedb_table_free(). On failure, table_out remains NULL.
A shallow clone creates a new table that shares the source’s data files while keeping an independent manifest. The clone therefore depends on those files remaining in the source table. The SDK currently supports shallow clones on embedded directory connections; a deep clone request fails with LANCEDB_NOT_SUPPORTED there.
The source and target strings, every string and component array reached from options, and the options struct itself are borrowed only for the duration of this call.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
target_table_name – - null-terminated C string containing the target table name
source_uri – - null-terminated C string containing the source table URI
options – - optional clone options (NULL for the SDK defaults)
table_out – - pointer to receive the cloned table
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_drop_table(const LanceDBConnection *connection, const char *table_name, const char *_namespace, char **error_message)
Drop a table from the database.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
table_name – - null-terminated C string containing the table name
_namespace – - null-terminated C string containing the namespace (NULL for no namespace)
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_drop_table_path(const LanceDBConnection *connection, const char *table_name, const char *const *namespace_path, size_t namespace_path_len, char **error_message)
Drop a table from a multi-level namespace path.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
table_name – - null-terminated C string containing the table name
namespace_path – - array of namespace component strings (NULL when namespace_path_len is 0)
namespace_path_len – - number of namespace components (0 for the root namespace)
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_rename_table(const LanceDBConnection *connection, const char *old_name, const char *new_name, const char *cur_namespace, const char *new_namespace, char **error_message)
Rename a table in the database.
Renaming is supported in LanceDB Enterprise and by namespace backends that implement it. Directory namespaces support renaming tables resolved through their manifest, including within or across child namespaces; directory-listing root tables cannot be renamed.
A NULL new_namespace omits the target namespace from the rename request. It does not promise a move to the root namespace. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
old_name – - null-terminated C string containing the current table name
new_name – - null-terminated C string containing the new table name
cur_namespace – - null-terminated C string containing the current namespace (NULL for no namespace)
new_namespace – - null-terminated C string containing the new namespace (NULL omits the target namespace)
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_rename_table_path(const LanceDBConnection *connection, const char *old_name, const char *new_name, const char *const *cur_namespace_path, size_t cur_namespace_path_len, const char *const *new_namespace_path, size_t new_namespace_path_len, char **error_message)
Rename a table between multi-level namespace paths.
Renaming is supported in LanceDB Enterprise and by namespace backends that implement it. Directory namespaces support renaming tables resolved through their manifest, including within or across child namespaces; directory-listing root tables cannot be renamed.
A zero-length new_namespace_path omits the target namespace from the rename request. It does not promise a move to the root namespace. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
old_name – - null-terminated C string containing the current table name
new_name – - null-terminated C string containing the new table name
cur_namespace_path – - array of current namespace components (NULL when cur_namespace_path_len is 0)
cur_namespace_path_len – - number of current namespace components (0 for the root namespace)
new_namespace_path – - array of new namespace components; zero length omits the target namespace
new_namespace_path_len – - number of new namespace components; zero omits the target namespace
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_drop_all_tables(const LanceDBConnection *connection, const char *_namespace, char **error_message)
Drop all tables in the database.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
_namespace – - null-terminated C string containing the namespace (NULL for no namespace)
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_drop_all_tables_path(const LanceDBConnection *connection, const char *const *namespace_path, size_t namespace_path_len, char **error_message)
Drop all tables in a multi-level namespace path.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
namespace_path – - array of namespace component strings (NULL when namespace_path_len is 0)
namespace_path_len – - number of namespace components (0 for the root namespace)
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_create_namespace(const LanceDBConnection *connection, const char *namespace_name, char **error_message)
Create a new namespace.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
namespace_name – - null-terminated C string containing the namespace name
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_create_namespace_path(const LanceDBConnection *connection, const char *const *namespace_path, size_t namespace_path_len, char **error_message)
Create a namespace at a multi-level namespace path.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
namespace_path – - array of namespace component strings (NULL when namespace_path_len is 0)
namespace_path_len – - number of namespace components (0 for the root namespace)
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_drop_namespace(const LanceDBConnection *connection, const char *namespace_name, char **error_message)
Drop a namespace.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
namespace_name – - null-terminated C string containing the namespace name
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_drop_namespace_path(const LanceDBConnection *connection, const char *const *namespace_path, size_t namespace_path_len, char **error_message)
Drop a namespace at a multi-level namespace path.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
namespace_path – - array of namespace component strings (NULL when namespace_path_len is 0)
namespace_path_len – - number of namespace components (0 for the root namespace)
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_list_namespaces(const LanceDBConnection *connection, const char *namespace_parent, char ***namespaces_out, size_t *count_out, char **error_message)
List all namespaces in the database.
The caller is responsible for freeing the returned strings and array using lancedb_free_namespace_list(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
namespace_parent – - null-terminated C string containing the parent namespace (NULL for root)
namespaces_out – - pointer to receive array of string pointers
count_out – - pointer to receive count of namespace names
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_list_namespaces_path(const LanceDBConnection *connection, const char *const *namespace_path, size_t namespace_path_len, char ***namespaces_out, size_t *count_out, char **error_message)
List all namespaces under a multi-level namespace path.
The caller is responsible for freeing the returned strings and array using lancedb_free_namespace_list(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
On entry, a non-NULL namespaces_out is set to NULL and a non-NULL count_out to zero. They are published only after the complete list has been converted. A non-NULL error_message is cleared on entry.
- Parameters:
connection – - pointer to LanceDBConnection
namespace_path – - array of namespace component strings (NULL when namespace_path_len is 0)
namespace_path_len – - number of namespace components (0 for the root namespace)
namespaces_out – - pointer to receive array of string pointers
count_out – - pointer to receive count of namespace names
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_connection_describe_namespace_path(const LanceDBConnection *connection, const char *const *namespace_path, size_t namespace_path_len, LanceDBNamespaceDescription *description_out, char **error_message)
Describe a namespace at a multi-level namespace path.
On entry, a non-NULL description_out is set to the empty description and a non-NULL error_message is cleared. The description is published only after the complete response has been converted.
On success, free the description with lancedb_free_namespace_description(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
namespace_path – - array of namespace component strings (NULL when namespace_path_len is 0)
namespace_path_len – - number of namespace components (0 for the root namespace)
description_out – - pointer to receive the namespace description
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
void lancedb_free_namespace_list(char **namespaces, size_t count)
Free namespace list array returned by lancedb_connection_list_namespaces.
After calling this function, the namespaces pointer must not be used.
- Parameters:
namespaces – - pointer to array returned by lancedb_connection_list_namespaces()
count – - count returned by lancedb_connection_list_namespaces()
-
void lancedb_free_namespace_description(LanceDBNamespaceDescription *description)
Free a namespace description returned by lancedb_connection_describe_namespace_path.
The arrays and their strings are freed and the fields are zeroed. The struct itself stays owned by the caller.
- Parameters:
description – - pointer to a description returned by lancedb_connection_describe_namespace_path(), or NULL
-
void lancedb_connection_free(LanceDBConnection *connection)
Free a Connection.
After calling this function, the connection pointer must not be used.
- Parameters:
connection – - pointer to LanceDBConnection returned from lancedb_connect_builder_execute()
-
struct LanceDBClientConfig
- #include <lancedb.h>
HTTP client configuration for a remote connection.
A NULL pointer or a zero-initialized struct keeps the SDK ClientConfig::default(), including the SDK user agent, empty extra headers, and no TLS configuration, which leaves the SDK/reqwest default hostname verification enabled. When the library is built with the remote feature, an unknown set_fields bit, a missing required array or invalid UTF-8 makes lancedb_connect_builder_client_config() return NULL and consume the builder. Builds without the remote feature consume the builder and leave it unchanged.
All strings, status codes and header arrays are borrowed for the duration of that call and copied into the SDK configuration. NULL string fields keep their SDK value. A non-NULL string, including an empty one, is passed unchanged. Negative or non-finite backoff values and invalid scalar values are left for the SDK to reject when the builder is executed, preserving its error code and message timing.
Timeouts use milliseconds and retry counts use the SDK’s uint8_t range. When a set_fields bit is present, its value is forwarded even when zero. The SDK still owns environment fallbacks: leaving a field unset lets the matching LANCE_CLIENT_* variable or the SDK default apply. user_id is NULL to keep the SDK LANCEDB_USER_ID / LANCEDB_USER_ID_ENV_KEY fallback, or a non-NULL string to set it explicitly. max_bytes_per_request and max_request_duration_ms use zero to disable their respective insert-request cut, as the SDK does.
Retry status codes are copied from retry_statuses when LANCEDB_CLIENT_CONFIG_RETRY_STATUSES is set. A zero retry_status_count with that bit selects an empty list and disables status retries; a non-zero count requires a non-NULL array. extra_header_count greater than zero requires both parallel header arrays and every entry to be non-NULL and valid UTF-8. Static extra headers replace the same SDK default headers when names collide. The SDK user agent and a configured or environment-derived user_id are applied afterward, so they take precedence over a static header with the same name.
A TLS configuration exists when any TLS path is non-NULL or LANCEDB_CLIENT_CONFIG_TLS_ASSERT_HOSTNAME is set. The SDK TlsConfig default asserts the server hostname, so leaving the bit unset keeps verification on; setting it with 0 explicitly disables it and with 1 keeps it on. Any other value makes the setter return NULL. tls_cert_file and tls_key_file are read only when both are configured; a lone client certificate or key path is not read. tls_ssl_ca_cert is read when configured. Missing or unreadable configured files, invalid certificate contents, invalid header names or values, an unsupported id_delimiter, a blob request concurrency outside the SDK’s positive semaphore range (including an environment-derived value) and invalid retry status codes are reported by lancedb_connect_builder_execute().
Callback-based header providers are not part of this plain-data structure. Native (non-db://) connections ignore the configuration, matching the other remote-only builder setters.
-
struct LanceDBOpenTableOptions
- #include <lancedb.h>
Options for lancedb_connection_open_table_with_options.
A zero-initialized struct keeps every SDK default. set_fields selects the scalar overrides; an unknown bit is rejected with LANCEDB_INVALID_ARGUMENT.
namespace_path is a borrowed array of namespace_path_len borrowed strings. Zero length is the root namespace and accepts a NULL array. A positive length requires a non-NULL array of non-NULL, NUL-terminated UTF-8 strings.
location and branch are borrowed strings. NULL leaves that option unset; a non-NULL string, including an empty one, is passed unchanged. For branch, the SDK treats “main” as the default branch. storage_keys and storage_values are parallel arrays of storage_count borrowed strings for this table only. A zero count omits per-table storage options. A non-zero count requires both arrays and every entry to be non-NULL and valid UTF-8.
index_cache_size and version are read only when their set_fields bit is set. Setting the bit selects the value, including zero, instead of treating zero as omitted. The SDK still owns precedence: an embedded open attaches the connection’s Session to the dataset builder, and that Session supplies the effective index cache capacity. An explicit index_cache_size, including zero, is therefore forwarded but does not resize or disable the Session’s cache. managed_versioning is also read only when its bit is set: 0 selects false and 1 selects true; every other value is rejected. Leaving the bit unset passes no managed-versioning preference.
The C layer forwards these options to the SDK unchanged. The SDK decides which backend accepts them and may resolve values from the backend. At the pinned SDK version:
An embedded listing root table uses location in place of the derived table path, and per-table storage options override connection options on the same key. index_cache_size follows the Session precedence above, so the connection Session’s current effective capacity remains in use. version selects a read-only detached snapshot. managed_versioning is forwarded, but a plain listing connection has no namespace client, so it does not enable namespace-managed commits.
An embedded namespace table (a non-empty namespace_path) gets its location, namespace storage options and managed-versioning state from the namespace. The SDK does not apply the request location or managed_versioning value to that open, and index_cache_size follows the Session precedence above. Per-table storage options are passed through, but namespace values win on the same key. version and branch still compose in the SDK after the namespace table is opened.
An Enterprise connection rejects index_cache_size, per-table storage options, location and managed_versioning (whether true or false) with LANCEDB_NOT_SUPPORTED. namespace_path is part of the table identifier, and version and branch are resolved by the server.
The options struct and every string it points to are borrowed for the duration of the call and are not consumed.
-
struct LanceDBCloneTableOptions
- #include <lancedb.h>
Options for lancedb_connection_clone_table().
A NULL options pointer or a zero-initialized struct keeps the SDK defaults: clone the source’s current version into the root namespace, fail when the target already exists, and perform a shallow clone.
source_version is read only when has_source_version is non-zero. source_tag is read only when non-NULL. An embedded directory connection rejects setting both when it reads the source. If exist_ok is non-zero and the target already exists, it opens the existing target without reading the source. On remote connections, the server determines how to handle the source selectors and exist_ok.
target_namespace is an array of namespace components; a zero length accepts NULL and selects the root namespace. A positive length requires a non-NULL array whose entries are non-NULL, NUL-terminated UTF-8 strings.
Setting has_is_shallow to a non-zero value and is_shallow to 0 requests a deep clone. Embedded directory connections return LANCEDB_NOT_SUPPORTED for a deep clone or a non-empty target namespace. Remote connections forward both settings to the server. A namespace connection rejects every clone.
The strings and array are borrowed for the duration of the call. The struct is borrowed and is not consumed.
-
struct LanceDBNamespaceDescription
- #include <lancedb.h>
Description of a namespace returned by lancedb_connection_describe_namespace_path.
property_keys and property_values are parallel arrays of property_count entries, and likewise for context_keys and context_values. has_properties and has_context distinguish a map the SDK omitted (false) from an empty map (true, with NULL arrays and a zero count).
-
enum LanceDBClientConfigField