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 import the production database into our development process, so I'm wondering if there is a way to convert from a postgres database dump to something sqlite3 can understand (just feeding it the postgres's dumped SQL gave many, many errors). Or would it be easier just to install postgres on windows? Thanks.
相关问题
- NOT DISTINCT query in mySQL
- SQL/SQL-LITE - Counting records after filtering
- Flush single app django 1.9
- Django distinct is not working
- PostgreSQL: left outer join syntax
STEP1: make a dump of your database structure and data
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
STEP4: use your database ;)
There are some converter tools around:
http://sqlite.com/cvstrac/wiki?p=ConverterTools
Probably, and doing so is very straightforward.
I found this blog entry which guides you to do these steps:
Create a dump of the PostgreSQL database.
Remove/modify the dump.
SET
SELECT pg_catalog.setval
t
’f
’Add
BEGIN;
as first line andEND;
as last lineRecreate an empty development database.
bundle exec rake db:migrate
Import the dump.
Of course connecting via ssh and creating a new db using rake are optional
It was VERY easy for me to do using the taps gem as described here: http://railscasts.com/episodes/342-migrating-to-postgresql
And I've started using the Postgres.app on my Mac (no install needed, drop the app in your Applications directory, although might have to add one line to your PATH envirnment variable as described in the documentation), with Induction.app as a GUI tool to view/query the database.