I'm developing an application where it lets users to establish many number of database connections with a has-many relationship between user and connections. The connections are passive until the user manually connects each. The motive is to perform queries on them, parallely.
I don't find good tutorials related to this, can you help me with some tips on how to accomplish this ?
After researching for a bit, turns out there's a much simpler approach using ActiveRecord Connection pool.
Make sure the model record can individually connect using
obj = ActiveRecord::Base.establish_connection(...spec...) obj.connection.exec_query("Select * from users") # the response is in the form of ActiveResult, which allows flexible operations around the result.
Close the connection once done with the database.