> This page is for Server SDKs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# migrate_sqlite_to_pgvector

> Migrate a .swsearch SQLite index to a pgvector collection in PostgreSQL.

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

## **Parameters**

**`sqlite_path`** `str` — required

Path to the source `.swsearch` file.

---

**`connection_string`** `str` — required

PostgreSQL connection string (e.g., `"postgresql://user:pass@host/db"`).

---

**`collection_name`** `str` — required

Name for the target pgvector collection.

---

**`overwrite`** `bool` — default: false

Drop and recreate the collection if it already exists.

---

**`batch_size`** `int` — default: 100

Number of chunks to insert per batch.

---

## **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")
```