1
votes

I have a database hosted on Amazon RDS. I am developing a Rails application with primary database as PostgreSQL. The Postgres database needs to be updated with data from RDS. I need to pull records from MySQL and then load it into Postgres.

Also, this is not database migrations.

One option is to create a secondary database (MySQL) in my rails application. But this does not seem a good option as I need to transfer data only when needed and not very frequently.

What is the best way to achieve this? Can this be done through pgloader?

UPDATE

This solved my issue. I just needed to read from MySQL and this is working fine. Are there any drawbacks for this approach?

1
Why not just export a CSV and then import it? If it isn't something done frequently, it might be best to go with a simple solution. It could also be easily automated if it needs to happen on a regular basis. - Sloan Thrasher
Can I export to CSV from within Rails while using Postgres as the primary database and without setting a secondary MySQL database? - nishant
Either connect to the mysql database from your rails application directly and pull whatever data you need or develop an api for the mysql database and use that. - Shadow
How and where can I develop an api for mysql? - nishant

1 Answers

0
votes

You can use PostgreSQL's Foreign Data Wrappers : your MySQL tables will be viewed as PostgreSQL tables. See : https://www.postgresql.org/docs/current/static/postgres-fdw.html