4

Why you may ask? Because i have built the app on mysql and need to start using postgres for GIS component of my app only. Eventually i will migrate to postgres completely but in the mean time would like to know if this is possible

2 Answers 2

10

If for instance you, in your database.yml have something like this (don't really recall the correct attributes, but I think you get the idea):

postgres:
    adapter: postgres
    database: gis

mysql:
    adapter: mysql
    database: app

Then, you could add

establish_connection :postgres 

in the models that should use the Postgres database. Of course, it might be easier to create an abstract class and make all the models to use that one instead since that is more DRYer.

class PostgresRecord::Base < ActiveRecord::Base
  self.abstract_class = true
  establish_connection :postgres
end

Or, since you are planning on migrating to Postgres eventually, you probably should do the opposite, make the Postgres database default and change the connection for the MySQL.

Sign up to request clarification or add additional context in comments.

Comments

-3

You just have con instantiate another ODBC connection with your new Postgres driver an use it to create query's. That's all.

1 Comment

I downvoted this because it's a poor quality answer and doesn't really explain why.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.