{"record":{"id":"04db9e4940c0e642","repo":"cocoindex-io/cocoindex","slug":"sqlite-vec-extension-must-be-loaded-for-vec0-virtu","errorCode":null,"errorMessage":"sqlite-vec extension must be loaded for vec0 virtual tables. Use connect(..., load_vec=True)","messagePattern":"sqlite-vec extension must be loaded for vec0 virtual tables\\. Use connect\\(\\.\\.\\., load_vec=True\\)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/sqlite/_target.py","lineNumber":1128,"sourceCode":"                value = getattr(row, col_name)\n\n            if value is not None and col.encoder is not None:\n                value = col.encoder(value)\n            out[col_name] = value\n        return out\n\n    def __coco_memo_key__(self) -> str:\n        return self._provider.memo_key\n\n\ndef _validate_vec0_config(\n    table_schema: TableSchema[Any],\n    virtual_table_def: Vec0TableDef,\n    managed_conn: ManagedConnection,\n) -> None:\n    \"\"\"Validate vec0 virtual table configuration.\"\"\"\n    if _VEC_EXTENSION not in managed_conn.loaded_extensions:\n        raise RuntimeError(\n            \"sqlite-vec extension must be loaded for vec0 virtual tables. \"\n            \"Use connect(..., load_vec=True)\"\n        )\n    has_vector_col = any(\n        col_def.type.startswith(\"float[\") for col_def in table_schema.columns.values()\n    )\n    if not has_vector_col:\n        raise ValueError(\n            \"vec0 virtual tables require at least one float[N] vector column\"\n        )\n    all_cols = set(table_schema.columns.keys())\n    invalid_partition = set(virtual_table_def.partition_key_columns) - all_cols\n    if invalid_partition:\n        raise ValueError(f\"Partition key columns not in schema: {invalid_partition}\")\n    invalid_aux = set(virtual_table_def.auxiliary_columns) - all_cols\n    if invalid_aux:\n        raise ValueError(f\"Auxiliary columns not in schema: {invalid_aux}\")\n    if len(table_schema.primary_key) != 1:","sourceCodeStart":1110,"sourceCodeEnd":1146,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/sqlite/_target.py#L1110-L1146","documentation":"`_validate_vec0_config` runs when creating a vec0 virtual table target and first checks that the sqlite-vec extension was actually loaded on the connection (by inspecting `managed_conn.loaded_extensions`). If not, it raises `RuntimeError` directing the user to `connect(..., load_vec=True)`, because vec0 tables cannot exist without the extension.","triggerScenarios":"Calling `table_target(...)` with a `Vec0TableDef` on a connection opened without `load_vec=True`; the `sqlite-vec` package missing so loading failed silently at connect time; extension loading blocked by the SQLite build.","commonSituations":"Vector example code copied without the matching `connect()` options; deployment environment lacking `sqlite-vec`; switching from an in-memory test DB (extension loaded) to a production connect call that omits it.","solutions":["Open the connection with `connect(path, load_vec=True)`","Install `sqlite-vec` and confirm import/load succeeds","Verify with a quick check that the extension loads in your SQLite build before running the pipeline"],"exampleFix":"// before\nconn = sqlite.connect(\"vectors.db\")\n// after\nconn = sqlite.connect(\"vectors.db\", load_vec=True)","handlingStrategy":"validation","validationCode":"conn = sqlite.connect(path, load_vec=True)\nassert \"vec0\" in conn.loaded_extensions, \"sqlite-vec failed to load\"","typeGuard":null,"tryCatchPattern":"try:\n    target = sqlite.table_target(\"vecs\", virtual_table_def=Vec0TableDef(...), ...)\nexcept RuntimeError as e:\n    if \"sqlite-vec extension must be loaded\" in str(e):\n        install_or_enable_vec()\n    else:\n        raise","preventionTips":["Never construct Vec0TableDef targets on connections opened without load_vec=True","Add sqlite-vec to install requirements and verify loading at app startup","Use one connection factory for all environments"],"tags":["sqlite","sqlite-vec","vector","extension"],"backgroundTag":"missing-dependency","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}