Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to migrate from SQLite to PostgreSQL (Rails)

I'm a DB noob so please be kind with me.

I'm having some issues pushing my SQLite DB to Heroku via taps gem. Talking with them, they told me one of the solutions could be converting locally my DB from SQLite to PostgreSQL. Is there an easy way to do so?

Thanks

More info: - DB from Rails app - I'm on Mac OS X - Just installed PostgreSQL via macports

like image 836
Leonardo Dario Perna Avatar asked Nov 22 '10 17:11

Leonardo Dario Perna


People also ask

How do I change SQLite to Postgres?

Steps for Connecting SQLite to PostgreSQLStep 1: Create SQLite DB Dumpdata Backup. Step 2: Generate a Postgres DB and User. Step 3: Configure Settings.py. Step 4: Import Required Fixture via Loaddata from SQLite to PostgreSQL.

Is PostgreSQL better than SQLite?

SQLite doesn't perform well when it comes to user management. It also lacks the ability to handle simultaneous access by multiple users. PostgreSQL performs very well in managing users. It has well-defined permission levels for users that determine what operations they can perform in the database.

Can SQLite connect to PostgreSQL?

Using CData Sync, you can replicate SQLite data to PostgreSQL. To add a replication destination, navigate to the Connections tab. Click Add Connection.

Is SQLite faster than Postgres?

SQLite 2.7. 6 is significantly faster (sometimes as much as 10 or 20 times faster) than the default PostgreSQL 7.1. 3 installation on RedHat 7.2 for most common operations.


2 Answers

sqlite3 development.db .dump | psql dbname username

like image 115
jxpx777 Avatar answered Nov 08 '22 10:11

jxpx777


Sequel will help you

gem install sequel

sequel -C sqlite://db/development.sqlite3 postgres://username:password@localhost/dbname
like image 33
Mikhail Chuprynski Avatar answered Nov 08 '22 09:11

Mikhail Chuprynski