Files
lancedb/docs/web/snippets/attach_database.mdx
T
Xuanwo 36814ac87b docs: clarify Enterprise migration writes and row caches (#5348)
The Attach Database guide now shows how to switch writers to the
Enterprise SDK or SQL and how to request a fresh read. It also shows how
to retain a tagged snapshot for cached row addresses or rebuild a cache
with business keys or stable row IDs that are already enabled on the
target table.

The saved Enterprise 1.12.0, 1.13.0, and 1.14.0 editions omit this
migration guidance. The six Python examples ran with Enterprise 1.16.0
and Python SDK 0.42.1 on both directory and manifest catalogs. With a
configured 60-second weak read interval, a primed reader still saw v1
after a bare URI commit. The zero interval and `checkout_latest()` each
read v2 in independent cases.

Related issues are [OSS-3150](https://linear.app/lancedb/issue/OSS-3150)
and [OSS-3151](https://linear.app/lancedb/issue/OSS-3151).
2026-12-02 08:46:47 +00:00

15 lines
1.7 KiB
Plaintext

{/* Auto-generated by scripts/mdx_snippets_gen.py. Do not edit manually. */}
export const PyAttachBuildStableIdCache = "table = db.open_table(table_name, namespace_path=namespace_path, branch=branch)\ntable.checkout_latest()\ncached_rows = (\n table.search()\n .where(\"sample_id IN (101, 103)\")\n .select([\"sample_id\"])\n .with_row_id(True)\n .limit(2)\n .to_list()\n)\nids_by_key = {row[\"sample_id\"]: row[\"_rowid\"] for row in cached_rows}\n";
export const PyAttachReadCachedSnapshot = "snapshot = db.open_table(table_name, namespace_path=namespace_path, branch=branch)\nsnapshot.checkout(tag)\nif snapshot.version != cached_version:\n raise RuntimeError(f\"Tag {tag} no longer points to version {cached_version}\")\n\nrows = snapshot.search().where(f\"_rowaddr = {cached_address}\").limit(1).to_list()\n";
export const PyAttachReadStableIdCache = "table.checkout_latest()\nrow_ids = [ids_by_key[101], ids_by_key[103]]\nrows = table.take_row_ids(row_ids, with_row_id=True).to_list()\nrows_by_id = {row[\"_rowid\"]: row for row in rows}\nbatch = [rows_by_id.get(row_id) for row_id in row_ids]\n";
export const PyAttachReadZeroInterval = "from datetime import timedelta\n\nfresh_db = lancedb.connect(\n database_uri,\n read_consistency_interval=timedelta(0),\n **connection_options,\n)\nfresh_reader = fresh_db.open_table(\n table_name, namespace_path=namespace_path, branch=branch\n)\nlatest_count = fresh_reader.count_rows()\n";
export const PyAttachRefreshReader = "reader.checkout_latest()\nrefreshed_count = reader.count_rows()\n";
export const PyAttachTagCachedVersion = "tag = \"training-run-42\"\ntable = db.open_table(table_name, namespace_path=namespace_path, branch=branch)\ntable.tags.create(tag, cached_version)\n";