From 27b90a2ab9e536c0170bf71a4cbce60190178741 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Fri, 25 May 2018 15:53:36 -0400 Subject: [PATCH] setup pncc import --- sample_pnc/define.sql | 74 +++++++++++++++++++++++++++++++++++++++++++ sample_pnc/dump.cmd | 2 ++ sample_pnc/import.sql | 0 sample_pnc/srce.json | 67 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 sample_pnc/define.sql create mode 100644 sample_pnc/dump.cmd create mode 100644 sample_pnc/import.sql create mode 100644 sample_pnc/srce.json diff --git a/sample_pnc/define.sql b/sample_pnc/define.sql new file mode 100644 index 0000000..84a0a9d --- /dev/null +++ b/sample_pnc/define.sql @@ -0,0 +1,74 @@ +SELECT + * +FROM + tps.srce_set( + $$ + { + "name": "PNCC", + "type": "csv", + "descr": "PNC Cash Accounts", + "constraint": [ + "{AsOfDate}" + ], + "schemas": { + "default": [ + { + "path": "{AsOfDate}", + "type": "date", + "column_name": "AsOfDate" + }, + { + "path": "{BankId}", + "type": "text", + "column_name": "BankID" + }, + { + "path": "{AccountNumber}", + "type": "text", + "column_name": "AccountNumber" + }, + { + "path": "{AccountName}", + "type": "text", + "column_name": "AccountName" + }, + { + "path": "{BaiControl}", + "type": "text", + "column_name": "BaiControl" + }, + { + "path": "{Currency}", + "type": "text", + "column_name": "Currency" + }, + { + "path": "{Transaction}", + "type": "text", + "column_name": "Transaction" + }, + { + "path": "{Reference}", + "type": "text", + "column_name": "Reference" + }, + { + "path": "{Amount}", + "type": "text", + "column_name": "Amount" + }, + { + "path": "{Description}", + "type": "text", + "column_name": "Description" + }, + { + "path": "{AdditionalRemittance}", + "type": "text", + "column_name": "CurrencyAdditionalRemittance" + } + ] + } +} + $$::jsonb + ) \ No newline at end of file diff --git a/sample_pnc/dump.cmd b/sample_pnc/dump.cmd new file mode 100644 index 0000000..f835af6 --- /dev/null +++ b/sample_pnc/dump.cmd @@ -0,0 +1,2 @@ +psql -U ptrowbridge -d ubm -p 5432 -h ushcc10091 -c "COPY (SELECT jsonb_agg(rec) rec from tps.trans where srce = 'PNCC') TO 'c:\users\ptrowbridge\downloads\pncc.csv' WITH (format csv, header true)" +psql -U ptrowbridge -d ubm_dev -p 5432 -h ushcc10091 -c "CREATE TEMP TABLE x(j jsonb); COPY x FROM 'c:\users\ptrowbridge\downloads\pncc.csv' with (format csv, header true); SELECT * FROM x JOIN LATERAL tps.srce_import('PNCC',x.j) ON TRUE; DROP TABLE X;" \ No newline at end of file diff --git a/sample_pnc/import.sql b/sample_pnc/import.sql new file mode 100644 index 0000000..e69de29 diff --git a/sample_pnc/srce.json b/sample_pnc/srce.json new file mode 100644 index 0000000..a75a534 --- /dev/null +++ b/sample_pnc/srce.json @@ -0,0 +1,67 @@ +{ + "name": "PNCC", + "type": "csv", + "descr": "PNC Cash Accounts", + "constraint": [ + "{AsOfDate}" + ], + "schemas": { + "default": [ + { + "path": "{AsOfDate}", + "type": "date", + "column_name": "AsOfDate" + }, + { + "path": "{BankId}", + "type": "text", + "column_name": "BankID" + }, + { + "path": "{AccountNumber}", + "type": "text", + "column_name": "AccountNumber" + }, + { + "path": "{AccountName}", + "type": "text", + "column_name": "AccountName" + }, + { + "path": "{BaiControl}", + "type": "text", + "column_name": "BaiControl" + }, + { + "path": "{Currency}", + "type": "text", + "column_name": "Currency" + }, + { + "path": "{Transaction}", + "type": "text", + "column_name": "Transaction" + }, + { + "path": "{Reference}", + "type": "text", + "column_name": "Reference" + }, + { + "path": "{Amount}", + "type": "text", + "column_name": "Amount" + }, + { + "path": "{Description}", + "type": "text", + "column_name": "Description" + }, + { + "path": "{AdditionalRemittance}", + "type": "text", + "column_name": "CurrencyAdditionalRemittance" + } + ] + } +} \ No newline at end of file