예: 표준 인증 방법을 사용하는 Cloudant 대상에 대한 업로드 명령의 생성을 포함하는 데이터 언로드
실행 보고서:
[i1055@quickstart ~]$ db2hpu -i i1055 --debug -f sysin
INZM031I Optim High Performance Unload for Db2 06.01.00.001(160126)
64 bits 01/29/2016 (Linux quickstart.cloudera 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64)
INZI473I Memory limitations: 'unlimited' for virtual memory and 'unlimited' for data segment
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+
000001 GLOBAL CONNECT TO SAMPLE;
000002 UNLOAD TABLESPACE
000003 SELECT EMPNO, FIRSTNME, LASTNAME FROM EMPLOYEE;
000004 OUTFILE("outfile")
000005 LOADFILE("loadfile")
000006 LOADDEST (NOSQL_DB CLOUDANT WITH STANDARD AUTH)
000007 FORMAT JSON;
INZU462I HPU control step start: 01/29/2016 09:56:57.695.
INZU463I HPU control step end : 01/29/2016 09:56:58.748.
INZU464I HPU run step start : 01/29/2016 09:56:58.925.
INZU410I HPU utility has unloaded 42 rows on quickstart host for I1055.EMPLOYEE in outfile.
INZU684I HPU utility has generated an upload command for the CLOUDANT destination in the loadfile file.
INZU465I HPU run step end : 01/29/2016 09:57:00.305.
INZI441I HPU successfully ended: Real time -> 0m2.609369s
User time -> 0m0.628903s : Parent -> 0m0.625904s, Children -> 0m0.002999s
Syst time -> 0m0.056990s : Parent -> 0m0.046992s, Children -> 0m0.009998s
db2hpu.dest 파일의 연관된 Cloudant 섹션:
[Cloudant]
url=http://foo.cloudant.com
dbname=db1
user=foo
생성된 출력 파일에서 발췌한 내용:
[i1055@quickstart ~]$ cat outfile
{"docs":[
{"EMPNO":"000010","FIRSTNME":"CHRISTINE","LASTNAME":"HAAS"},
{"EMPNO":"000020","FIRSTNME":"MICHAEL","LASTNAME":"THOMPSON"},
...
{"EMPNO":"200330","FIRSTNME":"HELENA","LASTNAME":"WONG"},
{"EMPNO":"200340","FIRSTNME":"ROY","LASTNAME":"ALONZO"}
]}
생성된 업로드 명령:
[i1055@quickstart ~]$ cat loadfile
#!/bin/sh
echo "Enter password for user 'foo':"
read -s password
echo Start uploading ...
curl --write-out "%{http_code}" -X POST -H "Content-Type: application/json" --user foo:$password
http://foo.cloudant.com/db1/_bulk_docs -d "@outfile" -o "EMPLOYEE.msg" 2> "EMPLOYEE.msg.err"
RC=$?
if [ $RC -eq 0 ]
then
RC=$(cat "EMPLOYEE.msg.http")
if [ $RC -ge 300 -o $RC -lt 100 ]
then
RC=1
else
RC=0
rm -f "EMPLOYEE.msg.err"
fi
else
RC=1
fi
rm -f "EMPLOYEE.msg.http" >/dev/null 2>&1
if [ $RC -ne 0 ]
then
echo "An error occurred while processing the 'outfile' file. The 'EMPLOYEE.msg' and 'EMPLOYEE.msg.err' files
contain the associated execution reports."
else
echo "The 'outfile' file has been processed successfully. The 'EMPLOYEE.msg' file contains the associated execution report."
fi
exit $RC