pgloader is a data loading tool for PostgreSQL written in Common Lisp. It migrates data from MySQL, SQLite, MS SQL Server, PostgreSQL, CSV, fixed-width, DBF, and IXF sources into PostgreSQL using the COPY protocol, with automatic error handling (rejected rows go to a separate file instead of aborting the whole load).
make # Build pgloader binary → build/bin/pgloader
make CL=ccl # Build with Clozure CL instead of SBCL
make DYNSIZE=1024 # Adjust dynamic space size (default 16384 MB)
make clean # Remove all build artifactsFirst build downloads Quicklisp and all dependencies — takes significant time. Requires: SBCL (or CCL), git, curl, libsqlite3-dev, freetds-dev.
Tests require a running PostgreSQL instance.
# Prepare test databases (needs postgres superuser)
make -C test prepare
# Run regression suite
make test
# Run a single test
cd test && ../build/bin/pgloader csv.load
# Run single regression test (compares output)
cd test && ../build/bin/pgloader --regress csv.loadTest .load files are in test/. Regression tests are defined in test/Makefile REGRESS variable (32 tests). Some tests need MySQL (sakila) or external archives (REMOTE).
Source → Parser → Source Object → Copy Pipeline (batched, parallel) → PostgreSQL COPY → Target DB
↓
Reject File (bad rows logged, good rows continue)
src/parsers/— PEG parser (esrap) for pgloader's.loadfile DSL.command-*.lispfiles parse individual syntax elements;command-parser.lisporchestrates.src/sources/— CLOS-based source implementations. Each format (csv/, mysql/, sqlite/, mssql/, pgsql/, fixed/, db3/, ixf/) extendsmd-connectionandmd-copyfromcommon/.src/pgsql/— PostgreSQL target: connections (postmodern), DDL generation, schema discovery, index/constraint creation.src/pg-copy/— COPY protocol: batch processing, format conversion, queue-based streaming, retry logic. S3 integration for Redshift.src/load/— Orchestration:api.lispdefinescopy-from,copy-to,copy-database.migrate-database.lisphandles full migrations.src/utils/— State tracking, monitoring, reject handling, threading (lparallel), catalog metadata (CLOS structs), transforms/casting.src/main.lisp— CLI entry point (mainfunction), argument parsing.
Adding a new source format: create a subdirectory in src/sources/, define CLOS classes extending md-connection and md-copy, implement the generic functions from src/sources/common/, add parser rules in src/parsers/.
- pgloader.asd — ASDF system definition (all ~287 components)
- Quicklisp — Package manager, bootstrapped into
build/quicklisp/ - buildapp — Creates standalone executable from compiled Lisp image
- Local project overrides cloned into
build/quicklisp/local-projects/: qmynd, cl-ixf, cl-db3, cl-csv
postmodern (PostgreSQL), qmynd (MySQL protocol), esrap (PEG parser), lparallel (threading), cl-csv, sqlite, mssql (FreeTDS), drakma (HTTP), cl-ppcre (regex), zs3 (AWS S3).