http://www.postgresonline.com/journal/archives/325-Using-wget-directly-from-PostgreSQL-using-COPY-FROM-PROGRAM.html
CREATE TABLE worldbank_json(data json); COPY worldbank_json FROM PROGRAM 'C:/wget/wget.exe -q -O - "$@" "http://api.worldbank.org/countries?format=json&per_page=100&page=1"'; COPY worldbank_json FROM PROGRAM 'C:/wget/wget.exe -q -O - "$@" "http://api.worldbank.org/countries?format=json&per_page=100&page=2"'; COPY worldbank_json FROM PROGRAM 'C:/wget/wget.exe -q -O - "$@" "http://api.worldbank.org/countries?format=json&per_page=100&page=3"'; WITH je AS (SELECT json_array_elements(data->1) AS jd FROM worldbank_json) SELECT jd->>'id' AS id, jd->>'name' As country, jd#>>'{adminregion,id}' As region_id FROM je ;