***

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

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

Migrate a `.swsearch` SQLite index to a pgvector collection in PostgreSQL.
Chunks are transferred in batches with their embeddings, metadata, and tags preserved.

## **Parameters**

<ParamField path="sqlite_path" type="str" required={true} toc={true}>
  Path to the source `.swsearch` file.
</ParamField>

<ParamField path="connection_string" type="str" required={true} toc={true}>
  PostgreSQL connection string (e.g., `"postgresql://user:pass@host/db"`).
</ParamField>

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

<ParamField path="overwrite" type="bool" default="false" toc={true}>
  Drop and recreate the collection if it already exists.
</ParamField>

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

## **Returns**

`dict[str, Any]` -- Migration statistics containing:

* `source` (str) -- source file path
* `target` (str) -- target collection name
* `chunks_migrated` (int) -- number of successfully migrated chunks
* `errors` (int) -- number of failed chunks
* `config` (dict) -- source index configuration

## **Example**

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

migrator = SearchIndexMigrator(verbose=True)
stats = migrator.migrate_sqlite_to_pgvector(
    sqlite_path="./knowledge.swsearch",
    connection_string="postgresql://user:pass@localhost/mydb",
    collection_name="knowledge",
    overwrite=True,
)

print(f"Migrated {stats['chunks_migrated']} chunks with {stats['errors']} errors")
```