Go to file
Dimitri Fontaine 5e18cfd7d4 Implement support for partial indexes.
MS SQL has a notion of a "filtered index" that matches the notion of a
PostgreSQL partial index: the index only applies to the rows matching
the index WHERE clause, or filter.

The WHERE clause in both case are limited to simple expressions over a
base table's row at a time, so we implement a limited WHERE clause
parser for MS SQL filters and a transformation routine to rewrite the
clause in PostgreSQL slang.

In passing, we transform the filter constants using the same
transformation functions as in the CAST rules, so that e.g. a MS SQL
bit(1) value that got transformed into a PostgreSQL boolean is properly
translated, as in the following example:

  MS SQL:     "([deleted]=(0))"  (that's from the catalogs)
  PostgreSQL: deleted = 'f'

Of course the parser is still very badly tested, let's see what happens
in the wild now.

(Should) Fix #365.
2016-03-21 23:39:45 +01:00
build Add a bundle distribution. 2016-01-31 21:47:14 +01:00
bundle Add a bundle distribution. 2016-01-31 21:47:14 +01:00
conf Update the VM setup, use sid to build the debian package. 2014-09-10 22:30:47 +02:00
debian Implement ALTER TABLE clause for MySQL migrations. 2016-03-06 21:51:33 +01:00
src Implement support for partial indexes. 2016-03-21 23:39:45 +01:00
test Allow setting search_path with multiple schemas. 2016-03-20 20:54:08 +01:00
web Make it easier to contact me from the moral license. 2015-09-06 22:00:02 +02:00
.dockerignore Implement a Dockerfile. 2016-01-04 21:05:46 +01:00
.gitignore Review website material, introduce pgloader cli operations. 2015-01-15 16:52:10 +01:00
.travis.yml Travis: prepare an "err" schema. 2015-11-23 15:26:18 +01:00
bootstrap-centos7.sh Adds bootstrap for CentOS 7 2015-04-23 13:48:17 +02:00
bootstrap-centos.sh Fix the centos bootstrap script. 2014-01-03 16:49:31 +01:00
bootstrap-debian.sh Update the VM setup, use sid to build the debian package. 2014-09-10 22:30:47 +02:00
Dockerfile Improve the Dockerfile and the versioning. 2016-01-07 10:21:52 +01:00
INSTALL.md Easier install by detecting SBCL core-compression. 2016-01-09 22:17:02 -05:00
Makefile Remove platform specific tar options. 2016-02-02 15:28:00 +01:00
pgloader.1 Document --dry-run and --on-error-stop options. 2016-03-21 21:24:39 +01:00
pgloader.1.md Document --dry-run and --on-error-stop options. 2016-03-21 21:24:39 +01:00
pgloader.asd Implement support for partial indexes. 2016-03-21 23:39:45 +01:00
pgloader.lisp Cleanup. 2014-08-28 13:43:01 +02:00
pgloader.spec Fix incorrect dates in specfile 2015-03-09 00:47:07 +00:00
README.md Easier install by detecting SBCL core-compression. 2016-01-09 22:17:02 -05:00
TODO.md Fixed typos 2015-02-18 23:17:16 +00:00
Vagrantfile Allow pgloader to work on windows. 2014-11-06 22:12:20 +01:00

PGLoader

Build Status

Join the chat at https://gitter.im/dimitri/pgloader

pgloader is a data loading tool for PostgreSQL, using the COPY command.

Its main advantage over just using COPY or \copy, and over using a Foreign Data Wrapper, is its transaction behaviour, where pgloader will keep a separate file of rejected data, but continue trying to copy good data in your database.

The default PostgreSQL behaviour is transactional, which means that any erroneous line in the input data (file or remote database) will stop the entire bulk load for the table.

pgloader also implements data reformatting, a typical example of that being the transformation of MySQL datestamps 0000-00-00 and 0000-00-00 00:00:00 to PostgreSQL NULL value (because our calendar never had a year zero).

Versioning

pgloader version 1.x is quite old and was developed in TCL. When faced with maintaining that code, the new emerging development team (hi!) picked python instead because that made sense at the time. So pgloader version 2.x was written in python.

The current version of pgloader is the 3.x series, which is written in Common Lisp for better development flexibility, runtime performance, and support of real threading.

The versioning is now following the Emacs model, where any X.0 release number means you're using a development version (alpha, beta, or release candidate). The next stable versions are going to be 3.1 then 3.2 etc.

When using a development snapshot rather than a released version the version number includes the git hash (in its abbreviated form):

  • pgloader version "3.0.99"

    Release candidate 9 for pgloader version 3.1, with a git tag named v3.0.99 so that it's easy to checkout the same sources as the released code.

  • pgloader version "3.0.fecae2c"

    Development snapshot again git hash fecae2c. It's possible to have the same sources on another setup with using the git command git checkout fecae2c.

  • pgloader version "3.1.0"

    Stable release.

LICENCE

pgloader is available under The PostgreSQL Licence.

INSTALL

You can install pgloader directly from apt.postgresql.org and from official debian repositories, see packages.debian.org/pgloader.

$ apt-get install pgloader

You can also use a docker image for pgloader at https://hub.docker.com/r/dimitri/pgloader/:

$ docker pull dimitri/pgloader
$ docker run --rm --name pgloader dimitri/pgloader:latest pgloader --version
$ docker run --rm --name pgloader dimitri/pgloader:latest pgloader --help

Build from sources

pgloader is now a Common Lisp program, tested using the SBCL (>= 1.1.14) and Clozure CL implementations with Quicklisp.

$ apt-get install sbcl unzip libsqlite3-dev make curl gawk freetds-dev libzip-dev
$ cd /path/to/pgloader
$ make pgloader
$ ./build/bin/pgloader --help

When building from sources, you should always build from the current git HEAD as it's basically the only source that is managed in a way to ensure it builds aginst current set of dependencies versions.

More options when building from source

The Makefile target pgloader knows how to produce a Self Contained Binary file for pgloader, found at ./build/bin/pgloader:

$ make pgloader

By default, the Makefile uses SBCL to compile your binary image, though it's possible to build using CCL.

$ make CL=ccl pgloader

If using SBCL and it supports core compression, the make process will use it to generate a smaller binary. To force disabling core compression, you may use:

$ make COMPRESS_CORE=no pgloader

The --compress-core is unique to SBCL, so not used when CC is different from the sbcl value.

You can also tweak the default amount of memory that the pgloader image will allow itself using when running through your data (don't ask for more than your current RAM tho):

$ make DYNSIZE=8192 pgloader

The make pgloader command when successful outputs a ./build/bin/pgloader file for you to use.

Usage

You can either give a command file to pgloader or run it all from the command line, see the pgloader quick start on http://pgloader.io for more details.

$ ./build/bin/pgloader --help
$ ./build/bin/pgloader <file.load>

For example, for a full migration from SQLite:

$ createdb newdb
$ pgloader ./test/sqlite/sqlite.db postgresql:///newdb

Or for a full migration from MySQL, including schema definition (tables, indexes, foreign keys, comments) and parallel loading of the corrected data:

$ createdb pagila
$ pgloader mysql://user@localhost/sakila postgresql:///pagila

See the documentation file pgloader.1.md for details. You can compile that file into a manual page or an HTML page thanks to the ronn application:

$ apt-get install ruby-ronn
$ make docs