Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Dynamically reading from multiple identically structured DBs...?
2 Posts
Dynamically reading from multiple identically structured DBs...?

Apparently I can use "establish_connection" as I see fit.

Hi All,

I'm currently working with data from multiple existing databases. Each database contains identically structured (although different) data for various work sites. Basically each database is a collection of EVENT, TIMESTAMP, VALUE for various electrical work sites.

What I need to do is create a rails application that can dynamically access any of those "sites" to report data. I envision the following:

1) A main login/registration page that sends you to #2

2) A "Site List" page that basically lists available databases(as each DB is actually representative of the data from a single site) based on a required prefix so that the app can say for certain that it is a valid application database

3) Once a site is selected from #2 I can begin handing the data as if it were the "only" database around.

NOTE: I may desire to compare data from multiple "sites" on occasion so that is something I'd like to architect for if possible. Regardless, I need the most straightforward mechanism, or at least direction to some documentation on handling multiple databases in this capacity. I've seen many tutorials on "multiple connections", but none that are quite as dynamic as what I'm looking for.

Thanks in advance.

2 Posts
Login to add your message