How to convert a postgres database to sqlite

前端 未结 6 708
感动是毒
感动是毒 2020-12-01 16:51

We\'re working on a website, and when we develop locally (one of us from Windows), we use sqlite3, but on the server (linux) we use postgres. We\'d like to be able to impor

6条回答
  •  情话喂你
    2020-12-01 17:27

    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 ;)

提交回复
热议问题