From 165f74b197e3f53b22fbb06df82e347260f6385a Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Fri, 4 Oct 2013 17:12:50 +0200 Subject: [PATCH] Add some test files. --- test/load-from-archive.load | 71 +++++++++++++++++++++++++++++++++++++ test/my.load | 11 ++++++ 2 files changed, 82 insertions(+) create mode 100644 test/load-from-archive.load create mode 100644 test/my.load diff --git a/test/load-from-archive.load b/test/load-from-archive.load new file mode 100644 index 0000000..35b27eb --- /dev/null +++ b/test/load-from-archive.load @@ -0,0 +1,71 @@ + LOAD FROM ARCHIVE /Users/dim/Downloads/GeoLiteCity-latest.zip + INTO postgresql://dim@localhost:54393/ip4r + + BEFORE LOAD DO + $$ create extension if not exists ip4r; $$, + $$ create schema if not exists geolite; $$, + $$ create table if not exists geolite.location + ( + locid integer primary key, + country text, + region text, + city text, + postalcode text, + location point, + metrocode text, + areacode text + ); + $$, + $$ create table if not exists geolite.blocks + ( + iprange ip4r, + locid integer + ); + $$, + $$ drop index if exists geolite.blocks_ip4r_idx; $$, + $$ truncate table geolite.blocks, geolite.location cascade; + $$ + + LOAD CSV FROM FILENAME MATCHING ~/GeoLiteCity-Location.csv/ + WITH ENCODING iso-8859-1 + ( + locId, + country, + region null if blanks, + city null if blanks, + postalCode null if blanks, + latitude, + longitude, + metroCode null if blanks, + areaCode null if blanks + ) + INTO postgresql://dim@localhost:54393/ip4r?geolite.location + ( + locid,country,region,city,postalCode, + location point using (format nil "(~a,~a)" longitude latitude), + metroCode,areaCode + ) + WITH skip header = 2, + fields optionally enclosed by '"', + fields escaped by double-quote, + fields terminated by ',' + + AND LOAD CSV FROM FILENAME MATCHING ~/GeoLiteCity-Blocks.csv/ + WITH ENCODING iso-8859-1 + ( + startIpNum, endIpNum, locId + ) + INTO postgresql://dim@localhost:54393/ip4r?geolite.blocks + ( + iprange ip4r using (ip-range startIpNum endIpNum), + locId + ) + WITH skip header = 2, + fields optionally enclosed by '"', + fields escaped by double-quote, + fields terminated by ',' + + FINALLY DO + $$ + create index blocks_ip4r_idx on geolite.blocks using gist(iprange); + $$; diff --git a/test/my.load b/test/my.load new file mode 100644 index 0000000..8849d7e --- /dev/null +++ b/test/my.load @@ -0,0 +1,11 @@ +load database from mysql://localhost/adv + into postgresql://dim@localhost/adv + +with drop tables, truncate, create tables, create indexes, + reset sequences, + downcase identifiers + set work_mem to '128MB', maintenance_work_mem to '512 MB' + +cast type datetime to timestamptz drop default using zero-dates-to-null, + type date drop not null drop default using zero-dates-to-null, + type tinyint to boolean using tinyint-to-boolean;