pgloader 支持多種數據源數據的加載,以下列出簡單的操作命令,后邊會有詳細的使用說明
csv 格式內容加載
預備說明
需要先在pg 數據庫創建表
create table districts_longlat
(
usps text,
geoid text,
aland bigint,
awater bigint,
aland_sqmi double precision,
awater_sqmi double precision,
intptlat double precision,
intptlong double precision
);
csv文件加載格式
請求格式
pgloader --type csv \
--field id --field field \
--with truncate \
--with "fields terminated by ','" \
./test/data/matching-1.csv \
postgres:///pgloader?tablename=matching
標准輸入加載數據
pgloader --type csv \
--field "usps,geoid,aland,awater,aland_sqmi,awater_sqmi,intptlat,intptlong" \
--with "skip header = 1" \
--with "fields terminated by '\t'" \
- \
postgresql:///pgloader?districts_longlat \
< test/data/2013_Gaz_113CDs_national.txt
http 加載數據
pgloader --type csv \
--field "usps,geoid,aland,awater,aland_sqmi,awater_sqmi,intptlat,intptlong" \
--with "skip header = 1" \
--with "fields terminated by '\t'" \
http://pgsql.tapoueh.org/temp/2013_Gaz_113CDs_national.txt \
postgresql:///pgloader?districts_longlat
http 壓縮文件加載文件
curl http://pgsql.tapoueh.org/temp/2013_Gaz_113CDs_national.txt.gz \
| gunzip -c \
| pgloader --type csv \
--field "usps,geoid,aland,awater,aland_sqmi,awater_sqmi,intptlat,intptlong"
--with "skip header = 1" \
--with "fields terminated by '\t'" \
- \
postgresql:///pgloader?districts_longlat
從sqlite 遷移數據
請求格式
createdb newdb
pgloader ./test/sqlite/sqlite.db postgresql:///newdb
從mysql 遷移數據
請求格式
createdb pagila
pgloader mysql://user@localhost/sakila postgresql:///pagila
從遠程http加載壓縮dbf 文件
請求格式
createdb foo
pgloader --type dbf http://www.insee.fr/fr/methodes/nomenclatures/cog/telechargement/2013/dbf/historiq2013.zip postgresql:///foo
說明
實際上官方代碼倉庫包含了一個test 的目錄,里邊包含了測試腳本以及數據