examples/postgres_source/README.md
This example demonstrates how to use a PostgreSQL table as a source for CocoIndex v1. It reads structured product data from an existing table, computes derived fields, generates embeddings, and stores results in another PostgreSQL table.
We appreciate a star ⭐ at CocoIndex Github if this is helpful.
pip install -e .
Follow the CocoIndex PostgreSQL setup guide to install and configure PostgreSQL with pgvector extension.
Create source table source_products with sample data:
psql "postgres://cocoindex:cocoindex@localhost/cocoindex" -f ./prepare_source_data.sql
For simplicity, we use the same database for source and target. You can also set SOURCE_DATABASE_URL to use a separate database.
Build/update the index:
cocoindex update main.py
Query:
python main.py query "wireless headphones"