Noosphere Prime · Integrations · PostgreSQL FDW
PostgreSQL Foreign Data Wrapper
Query live SIGMA sovereign risk scores as if they were a native PostgreSQL table. Filter, join, aggregate — no ETL pipeline required. Data is cached locally for 1 hour and refreshed on-demand.
What you can do
SELECT name, flag, sigma_score, regime FROM sigma_scores WHERE sigma_score > 75 ORDER BY sigma_score DESC; -- name | flag | sigma_score | regime -- ---------------+------+-------------+--------- -- Turkey | 🇹🇷 | 82.4 | collapse -- Argentina | 🇦🇷 | 79.1 | stress -- Ukraine | 🇺🇦 | 77.6 | stress
Requirements
PostgreSQL
13+
Python
3.8+
multicorn2
via pip
Installation
1
Install Python dependenciespip install multicorn2 requests
2
Install multicorn2 PostgreSQL extension# Debian/Ubuntu sudo apt install postgresql-multicorn # macOS (Homebrew) brew install multicorn2 # From source git clone https://github.com/pgsql-io/multicorn2 cd multicorn2 && make && sudo make install
3
Download and place the FDW wrapper# Download noosphere_fdw.py curl -O https://noosphereprime.space/sdk/postgresql/noosphere_fdw.py # Place it in your Python path (site-packages or project dir) cp noosphere_fdw.py /usr/lib/python3/dist-packages/
4
Run the setup SQL-- In psql or pgAdmin: CREATE EXTENSION IF NOT EXISTS multicorn; CREATE SERVER noosphere FOREIGN DATA WRAPPER multicorn OPTIONS (wrapper 'noosphere_fdw.NoosphereWrapper'); CREATE FOREIGN TABLE sigma_scores ( slug text, name text, flag text, region text, sigma_score numeric, regime text, ews boolean, hurst_exponent numeric, r0_financial numeric, proof_url text, updated_at timestamp ) SERVER noosphere;
Example Queries
Countries in stress or collapse
SELECT name, flag, sigma_score, regime FROM sigma_scores WHERE sigma_score >= 65 ORDER BY sigma_score DESC;
Early Warning Signal active
SELECT name, region, sigma_score, proof_url FROM sigma_scores WHERE ews = true ORDER BY sigma_score DESC;
Regional risk aggregation
SELECT region,
COUNT(*) AS countries,
ROUND(AVG(sigma_score)::numeric, 2) AS avg_sigma
FROM sigma_scores
GROUP BY region
ORDER BY avg_sigma DESC;Materialized view (performance)
CREATE MATERIALIZED VIEW sigma_live AS
SELECT * FROM sigma_scores;
-- Refresh every hour via pg_cron:
SELECT cron.schedule('noosphere-refresh',
'0 * * * *',
'REFRESH MATERIALIZED VIEW sigma_live;');Schema Reference
| Column | Type | Description |
|---|---|---|
| slug | text | URL-safe country identifier (e.g. "romania") |
| name | text | Display name (e.g. "Romania") |
| flag | text | Unicode flag emoji |
| region | text | Geographic region (e.g. "Eastern Europe") |
| sigma_score | numeric | SIGMA fragility score 0–100 (higher = more fragile) |
| regime | text | robust | stable | warning | stress | collapse |
| ews | boolean | Early Warning Signal active |
| hurst_exponent | numeric | Hurst exponent (persistence of risk trend, 0–1) |
| r0_financial | numeric | Financial R0 — contagion reproduction number |
| proof_url | text | URL to verifiable proof page |
| updated_at | timestamp | When this row was last fetched from the API |
Downloads