# Multiple database read

**URL:** <https://www.ruby-forum.com/t/multiple-database-read/98032>\
**Category:** Rails\
**Created:** [January 27, 2006, 8:16pm UTC](https://www.ruby-forum.com/t/multiple-database-read/98032 "2006-01-27T20:16:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [January 27, 2006, 8:16pm UTC](https://www.ruby-forum.com/t/multiple-database-read/98032/1 "2006-01-27T20:16:45Z")

</div>

I have to extract data from an odbc connection to another database and  
put  
into a MySQL database so that my rails app can manipulate it. What  
would be  
the best way to set that up? Would I put the connection info in a  
controller, so that the controller method with open and close the  
connection? Any thought?

–  
Best Regards,  
-Larry  
“Work, work, work…there is no satisfactory alternative.”  
— E.Taft Benson

---

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [January 27, 2006, 8:28pm UTC](https://www.ruby-forum.com/t/multiple-database-read/98032/2 "2006-01-27T20:28:53Z")

</div>

Seems like there are a lot of people trying multiple database  
connections all the sudden. i have the read part down and not knowing  
more about what you are trying to do but I put the connection info in  
the model that is associated to the table that I want to read from. I  
have a users table in one database and in the app I have the  
following in the user.rb (model file)

establish\_connection(:adapter =\> “mysql”,  
:host =\> “localhost”,  
:port =\> 3306,  
:database =\> “GlobalUser\_development”,  
:username =\> “root”,  
:password =\> “root”)  
set\_table\_name “users”

This allows me to read all day long from the table and associate to  
the object from that table however I can’t get any of my actions to  
write to the table. and rails does not complain about it. When i  
click submit it goes through and acts like it made the change to the  
table however it doesn’t actually do it and the log file is not  
throwing any sort of exception.

hope this helps.

Andrew

---

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [January 28, 2006, 1:28am UTC](https://www.ruby-forum.com/t/multiple-database-read/98032/3 "2006-01-28T01:28:06Z")

</div>

Yes, this does help. I don’t need to right to the other database.  
Would  
you happen to know where to look for odbc adapter setting info?  
-Larry

On 1/27/06, Andrew F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> :port => 3306,
> 
> ```
> 
> throwing any sort of exception.
> 
> > and put into a MySQL database so that my rails app can manipulate  
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Best Regards,  
-Larry  
“Work, work, work…there is no satisfactory alternative.”  
— E.Taft Benson
