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 ;
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。