***

title: migrate_pgvector_to_sqlite
slug: /reference/python/agents/search/migrator/migrate-pgvector-to-sqlite
description: Migrate a pgvector collection to a SQLite .swsearch file.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

Create a SQLite `.swsearch` file from a pgvector collection's schema and
configuration.

<Warning>
  This method currently creates the SQLite schema and copies configuration only —
  **chunk data is not transferred**. Full chunk migration from pgvector to SQLite
  is planned for a future release. The returned `chunks_migrated` count will be `0`.
</Warning>

## **Parameters**

<ParamField path="connection_string" type="str" required={true} toc={true}>
  PostgreSQL connection string.
</ParamField>

<ParamField path="collection_name" type="str" required={true} toc={true}>
  Name of the source pgvector collection.
</ParamField>

<ParamField path="output_path" type="str" required={true} toc={true}>
  Output path for the `.swsearch` file. The `.swsearch` extension is appended
  automatically if not present.
</ParamField>

<ParamField path="batch_size" type="int" default="100" toc={true}>
  Number of chunks to fetch per batch.
</ParamField>

## **Returns**

`dict[str, Any]` -- Migration statistics with `source`, `target`, `chunks_migrated`,
`errors`, and `config` fields.

## **Example**

```python {4}
from signalwire.search import SearchIndexMigrator

migrator = SearchIndexMigrator(verbose=True)
stats = migrator.migrate_pgvector_to_sqlite(
    connection_string="postgresql://user:pass@localhost/mydb",
    collection_name="knowledge",
    output_path="./knowledge-backup.swsearch",
)

print(f"Migrated {stats['chunks_migrated']} chunks to {stats['target']}")
```