How to convert a postgres database to sqlite
I found this blog entry which guides you to do these steps:
Create a dump of the PostgreSQL database.
ssh -C [email protected] pg_dump --data-only --inserts YOUR_DB_NAME > dump.sql
Remove/modify the dump.
- Remove the lines starting with
SET
- Remove the lines starting with
SELECT pg_catalog.setval
- Replace true for ‘
t
’ - Replace false for ‘
f
’
- Remove the lines starting with
Add
BEGIN;
as first line andEND;
as last lineRecreate an empty development database.
bundle exec rake db:migrate
Import the dump.
sqlite3 db/development.sqlite3 sqlite> delete from schema_migrations; sqlite> .read dump.sql
Of course connecting via ssh and creating a new db using rake are optional
STEP1: make a dump of your database structure and data
pg_dump --create --inserts -f myPgDump.sql \
-d myDatabaseName -U myUserName -W myPassword
STEP2: delete everything except CREATE TABLES and INSERT statements out of myPgDump.sql (using text editor)
STEP3: initialize your SQLite database passing structure and data of your Postgres dump
sqlite3 myNewSQLiteDB.db -init myPgDump.sql
STEP4: use your database ;)
There are some converter tools around:
https://www2.sqlite.org/cvstrac/wiki?p=ConverterTools
Would it be easier just to install postgres on windows?
Probably, and doing so is very straightforward.