tps/deploy/reload/dcard/extract.sql

25 lines
794 B
MySQL
Raw Normal View History

2018-05-30 22:58:15 -04:00
--source
SELECT DEFN FROM TPS.SRCE WHERE SRCE = 'DCARD'
--mapdef
SELECT jsonb_agg(row_to_json(x)::jsonb) FROM (SELECT srce, target "name", regex, seq "sequence" FROM tps.map_rm WHERE srce = 'DCARD') x
--map values
SELECT jsonb_agg(row_to_JSON(x)::jsonb) FROM (SELECT srce "source", target "map", retval ret_val, "map" mapped FROM tps.map_rv WHERE srce = 'DCARD') X
--records
2018-05-29 23:14:41 -04:00
copy (
select
to_char(r."Trans. Date",'mm/dd/yyyy') "Trans. Date"
,to_char(r."Post Date",'mm/dd/yyyy') "Post Date"
,r."Description"
,r."Amount"
,r."Category"
from
tps.trans
join lateral jsonb_populate_record(null::tps.dcard, rec) r on true
where
srce = 'DCARD'
) to
2018-05-30 22:58:15 -04:00
'C:\users\fleet\downloads\dcard.csv' with (format csv, header true);