Use OKFN's tabular-data-package standard JSON descriptors to load dataset into SQL database, and option to express fields in JSONB. Use faster internal SQL COPY
(or BULK INSERT
).
There are no necessary preparation, use the prefered source file in your software, eg. src/packLoad.php.
NOTE. Similar to okfn/dptools/load-postgresql.py, but with important JSON field option.
To illustrate packLoad use with PHP in PostgreSQL 9.5+
git clone https://github.com/ppKrauss/sql-loadPack.git
cd sql-loadPack
sudo nano src/packLoad.php # change $PG_PW and other database configs
php sql-loadPack/src/example.php
and check the sandbox
at configurated database (psql
or pgAdminIII).
- Make desired tables, defined by your standard
datapackage.json
, with oneresourceLoad_run()
instruction. - Any additional pre or pos database preparation can be defined by
sql_prepare()
function. - Faster than any other conversion.
- Optional use of JSON or JSONB datatypes, as "catch-all" fields.
- Free table names, column names, etc.
- Options
prepared_copy
,prepare_auto
,prepare_json
, andprepare_jsonb
.
Important: at your datapackage.json
, in the resources/schema
, as the example, add property role
in the fields to be preserved as SQL (not encapsulating in JSON field). The default JSON field name is jinfo
.
All that you need is exemplified by src/example.lang
, see eg. example.php.