forked from dimitri/pgloader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
149 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,46 @@ | ||
TESTS = $(wildcard *.load) | ||
OUT = $(TESTS:.load=.out) | ||
|
||
all: $(OUT) | ||
REMOTE = archive.load bossa-all.load bossa.load census-places.load dbf-zip.load | ||
LOCAL = $(filter-out $(REMOTE:.load=.out),$(OUT)) | ||
|
||
PGLOADER ?= ../build/pgloader.exe | ||
|
||
local: prepare $(LOCAL) | ||
|
||
remote: prepare $(REMOTE:.load=.out) | ||
|
||
all: prepare $(OUT) | ||
|
||
sakila: ; | ||
# unzip data/sakila-db.zip | ||
# echo "SOURCE data/sakila-db/sakila-schema.sql" | mysql -u root | ||
# echo "SOURCE data/sakila-db/sakila-data.sql" | mysql -u root | ||
|
||
prepare: bossa.sql sakila | ||
-dropdb -U postgres pgloader | ||
-dropdb -U postgres stocks | ||
-dropdb -U postgres ip4r | ||
-createdb -U postgres -O `whoami` pgloader | ||
-createdb -U postgres -O `whoami` stocks | ||
-createdb -U postgres -O `whoami` ip4r | ||
-psql -U postgres -d pgloader -c 'create extension ip4r' | ||
-psql -U postgres -d ip4r -c 'create extension ip4r' | ||
-psql -d stocks -f bossa.sql | ||
|
||
# Some special cases where we expect errors and want to continue testing | ||
sakila.out: sakila.load | ||
@echo "no MySQL installation here." | ||
|
||
errors.out: errors.load | ||
-$(PGLOADER) $< | ||
@echo | ||
|
||
nofile.out: nofile.load | ||
-$(PGLOADER) $< | ||
@echo | ||
|
||
# General case where we do NOT expect any error | ||
%.out: %.load | ||
$(PGLOADER) --verbose $< | ||
$(PGLOADER) $< | ||
@echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* We load all the files in the archive, all of them into the same target table. | ||
*/ | ||
|
||
load archive | ||
from http://bossa.pl/pub/futures/mstock/mstfut.zip | ||
|
||
load csv | ||
from all filenames matching ~/./ | ||
with encoding iso-8859-2 | ||
( ticker | ||
, quote_date | ||
, open | ||
, high | ||
, low | ||
, close | ||
, volume | ||
, openint | ||
) | ||
into postgresql:///stocks?intf_derivatives | ||
with | ||
skip header=1 | ||
, fields optionally enclosed by '"' | ||
, fields terminated by ',' | ||
, truncate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
LOAD ARCHIVE | ||
FROM http://bossa.pl/pub/metastock/mstock/mstall.zip | ||
-- FROM /Users/dim/dev/temp/mstall.zip | ||
INTO postgresql:///stocks | ||
|
||
LOAD CSV | ||
FROM FILENAME MATCHING ~/ALIOR/ | ||
WITH ENCODING iso-8859-2 | ||
(ticker, quote_date, open, high, low, close, volume) | ||
INTO postgresql:///stocks?intf_stocks | ||
WITH | ||
SKIP HEADER=1, | ||
FIELDS OPTIONALLY ENCLOSED BY '"', | ||
FIELDS TERMINATED BY ',' | ||
|
||
AND LOAD CSV | ||
FROM FILENAME MATCHING ~/FPGNH14/ | ||
WITH ENCODING iso-8859-2 | ||
(ticker, quote_date, open, high, low, close, volume, openint) | ||
INTO postgresql:///stocks?intf_derivatives | ||
WITH | ||
SKIP HEADER = 1, | ||
FIELDS OPTIONALLY ENCLOSED BY '"', | ||
FIELDS TERMINATED BY ',' | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
--- We need to run some tests where we don't provide for the schema within | ||
--- the pgloader command itself, so we prepare the schema "manually" here in | ||
--- advance. | ||
--- | ||
|
||
drop table if exists intf_derivatives, intf_stocks; | ||
|
||
create table intf_stocks | ||
( | ||
ticker text, | ||
quote_date date, | ||
open numeric, | ||
high numeric, | ||
low numeric, | ||
close numeric, | ||
volume bigint | ||
); | ||
|
||
create table intf_derivatives | ||
( | ||
ticker text, | ||
quote_date date, | ||
open numeric, | ||
high numeric, | ||
low numeric, | ||
close numeric, | ||
volume bigint, | ||
openint bigint | ||
); |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
/* | ||
* The file comes from: | ||
* | ||
* http://www.insee.fr/fr/methodes/nomenclatures/cog/telechargement/2013/dbf/reg2013.dbf | ||
*/ | ||
LOAD DBF | ||
FROM http://www.insee.fr/fr/methodes/nomenclatures/cog/telechargement/2013/dbf/reg2013.dbf | ||
FROM data/reg2013.dbf | ||
INTO postgresql:///pgloader | ||
WITH truncate, create table | ||
SET client_encoding TO 'latin1'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
LOAD CSV | ||
FROM 'this/file/does/not/exists.csv' WITH ENCODING latin1 | ||
(a, b, c, d, e) | ||
INTO postgresql:///pgloader?csv.nofile | ||
|
||
WITH truncate, | ||
skip header = 1, | ||
fields optionally enclosed by '"', | ||
fields escaped by double-quote, | ||
fields terminated by ',' | ||
|
||
BEFORE LOAD DO | ||
$$ create schema if not exists csv; $$, | ||
$$ create table if not exists csv.nofile | ||
( | ||
a text, | ||
b text, | ||
c text, | ||
d text, | ||
e text | ||
); | ||
$$; |