pgloader
Migrate to PostgreSQL in a single command!
What is pgloader?
Migrate to PostgreSQL in a single command!
Overview of pgloader
What it is
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.pgloader v4 is a full rewrite in Clojure, distributed as a single self-contained JAR requiring Java 21 or later. It is a drop-in replacement for v3 and accepts the same .load file syntax and command-line flags.
Key features
- Transaction behaviour: keeps a separate file of rejected data while continuing to copy good data
- Data reformatting: transforms MySQL datestamps like 0000-00-00 to PostgreSQL NULL
- Single JAR distribution (v4) with no native dependencies
- JDBC connection strings: use jdbc:mysql://, jdbc:postgresql://, jdbc:sqlserver:// etc.
- SSL via URI: use ?sslmode=require or ?sslmode=disable in the connection string
- Supports migration from SQLite, MySQL, and other sources
Use cases
- Migrating data from MySQL to PostgreSQL, including schema definition (tables, indexes, foreign keys, comments) and parallel loading of corrected data
- Migrating data from SQLite to PostgreSQL
- Loading data from files into PostgreSQL with error tolerance
Getting started
Download the latest pre-release JAR:$ curl -L -o pgloader.jar https://github.com/dimitri/pgloader/releases/download/v4-dev/pgloader.jarRun pgloader:$ java -jar pgloader.jar --versionExample migration from SQLite:$ createdb newdb$ java -jar pgloader.jar ./test/sqlite/sqlite.db postgresql:///newdbExample migration from MySQL:$ createdb pagila$ java -jar pgloader.jar mysql://user@localhost/sakila postgresql:///pagilaFor full documentation, see the repository README.
License and pricing
pgloader is available under The PostgreSQL Licence. The project is open source.
這是什麼
pgloader 是一個使用 PostgreSQL COPY 指令的資料載入工具。它與單純使用 COPY 或 COPY,以及使用外部資料包裝器(Foreign Data Wrapper)相比,主要優勢在於其交易行為:pgloader 會保留一個獨立的拒絕資料檔案,同時繼續嘗試將正確資料複製到資料庫中。PostgreSQL 的預設行為是交易性的,這意味著輸入資料(檔案或遠端資料庫)中的任何錯誤行都會導致該表格的整個批次載入停止。pgloader 也實作了資料重新格式化,一個典型的例子是將 MySQL 的時間戳記 0000-00-00 和 0000-00-00 00:00:00 轉換為 PostgreSQL 的 NULL 值。pgloader v4 是用 Clojure 完全重寫的版本,以單一自包含的 JAR 檔案形式發行,需要 Java 21 或更新版本。它是 v3 的無痛替代品,並接受相同的 .load 檔案語法和命令列旗標。
主要功能
- 交易行為:保留拒絕資料的獨立檔案,同時繼續複製正確資料
- 資料重新格式化:將 MySQL 的時間戳記(如 0000-00-00)轉換為 PostgreSQL 的 NULL
- 單一 JAR 發行(v4),無需原生依賴
- JDBC 連線字串:使用 jdbc:mysql://、jdbc:postgresql://、jdbc:sqlserver:// 等
- 透過 URI 支援 SSL:在連線字串中使用 ?sslmode=require 或 ?sslmode=disable
- 支援從 SQLite、MySQL 及其他來源進行遷移
使用情境
- 將資料從 MySQL 遷移到 PostgreSQL,包括綱要定義(表格、索引、外鍵、註解)以及修正資料的平行載入
- 將資料從 SQLite 遷移到 PostgreSQL
- 從檔案載入資料到 PostgreSQL,並具備錯誤容忍能力
快速開始
下載最新的預發行 JAR:$ curl -L -o pgloader.jar https://github.com/dimitri/pgloader/releases/download/v4-dev/pgloader.jar執行 pgloader:$ java -jar pgloader.jar --version從 SQLite 遷移的範例:$ createdb newdb$ java -jar pgloader.jar ./test/sqlite/sqlite.db postgresql:///newdb從 MySQL 遷移的範例:$ createdb pagila$ java -jar pgloader.jar mysql://user@localhost/sakila postgresql:///pagila完整文件請參閱儲存庫的 README。
授權與價格
pgloader 採用 PostgreSQL 授權條款。此專案為開放原始碼。
Based on the project's public README and repository metadata.