Skip to main content

SQLite to PostgreSQL Migration (pgloader)

Install​

sudo apt-get install pgloader

Write a Config File​

LOAD DATABASE
FROM sqlite:///path/to/your/sqlite.db
INTO postgresql://username:password@localhost/your_postgresql_db
WITH
include no drop,
create tables,
create indexes,
reset sequences,
SET maintenance_work_mem to '512MB',
work_mem to '64MB',
search_path to 'public'

Execute​

pgloader migrate.load

Parameter Reference​

ParameterDescription
include no dropDon't drop existing tables in the target database
create tablesCreate tables in the target database
create indexesCreate indexes in the target database
reset sequencesReset auto-increment sequences to avoid conflicts
data onlyMigrate data only, skip schema
maintenance_work_memMemory allocated for maintenance tasks (e.g. building indexes)
work_memMemory allocated for query operations (sorting, joins)
search_path to 'public'Set PostgreSQL schema to public

Post-Migration State​

  • SQLite remains unchanged — pgloader only reads, never modifies
  • PostgreSQL will have new tables built from the SQLite schema, with all migrated data

Reference​