PostgreSQL's Foreign Data Wrapper (FDW) feature allows querying external data sources directly via SQL, treating them as virtual tables. The post covers four use cases: querying CSV files with the built-in file_fdw extension, connecting to another PostgreSQL database with postgres_fdw, accessing NoSQL databases like MongoDB using existing FDW extensions or custom ones built with Multicorn (a Python library), and wrapping REST APIs as queryable foreign tables. Multicorn enables building custom FDW extensions for virtually any data source, including authenticated APIs. The approach eliminates the need for custom ETL scripts or cron jobs to sync external data.
Table of contents
Querying a CSV FileQuerying Another PostgreSQL DatabaseQuerying A NoSQL DatabaseQuerying a REST APIConclusion1.8K Impressions