This example demonstrates how to use Kvatch CLI to query and join data from two separate PostgreSQL databases: one for books and one for authors.
kvatchCLI installed- Two PostgreSQL databases accessible (
booksandauthors) - Two secrets files with credentials:
The full plan is available in plan.yaml.
Key sections:
- Storage → SQLite DB
- Connectors → [books_db, authors_db]
- Datasets → [books, authors, author_books]
- Output → outputs the
author_booksdataset
kvatch query --plan examples/connectors/postgres/plan.yaml \
--secrets examples/connectors/postgres/secrets-authors.yaml,examples/connectors/postgres/secrets-books.yamlWhen you run the plan, you should see output similar to:
🚀 Results of Query (local mode):
────────────────────────────────────────────────────────────────────────
review | title | name
────────────────────────────────────────────────────────────────────────
Great but terrible ending | A Clash of Kings | george r r martin
Great but terrible ending | A Game of Thrones | george r r martin
Not about wolves | Wolf of the Plains | conn iggulden
────────────────────────────────────────────────────────────────────────
The results are written to the SQLite database defined in the plan.
Inspect the results with:
sqlite3 postgres-example.dbThen run:
SELECT * FROM author_books;- Secrets are loaded from two separate YAML files — one per database.
- Do not commit secrets to version control.