We have two options:
- Create a dump:
sqlite3 database.sqlite .dump > /path/to/sqlite-dumpfile.sql
- Or we can export all tables as CSV files
for table in $(sqlite3 database.sqlite ".tables"); do
echo $table
sqlite3 -header -csv \
database.sqlite "select * from $table;" > "$table.csv"
done
- Connect to Postgres using
psql
psql <postgres-connection-string>
- Change to the databse where you want to import
\c <your-database>
- Import each CSV file
\copy "<table-name>" from "<your/exports/table-name.csv>" delimiter ',' csv header;
TBD
This might find issues depending ont he structure of the tables and its data types
-
Create a
pgload.conf
file with:load database from 'database.sqlite' into postgresql:///testdb with include drop, create tables, create indexes, reset sequences set work_mem to '16MB', maintenance_work_mem to '512 MB';
-
Run:
pgloader pgload.conf