hai...friends.. how to create multiple mysql database ??pls help i ve used the following type but it creates only one database mobile_development..any help pls... development: adapter: mysql database: mobile_development timeout: 5000 username: root password: host: localhost environment_name1: adapter: mysql database: database1 username: root password: host: localhost environment_name2: adapter: mysql database: database2 username: root password: host: localhost test: adapter: mysql database: mobile_test timeout: 5000 username: root password: host: localhost production: adapter: mysql database: mobile_production timeout: 5000 username: root password: host: localhost -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 3 Jul 2008, at 10:44, Jai Jai wrote:> > hai...friends.. > how to create multiple mysql database ??pls help > i ve used the following type but it creates only one database > mobile_development..any help pls... >I don''t know what you''ve done beyond edit database.yml, but at the very least you''re going to need to indent it properly: the environment_name1 and environment_name2 entries you''ve added aren''t indented like the other ones. Fred> > development: > adapter: mysql > database: mobile_development > timeout: 5000 > username: root > password: > host: localhost > environment_name1: > adapter: mysql > database: database1 > username: root > password: > host: localhost > > environment_name2: > adapter: mysql > database: database2 > username: root > password: > host: localhost > test: > adapter: mysql > database: mobile_test > timeout: 5000 > username: root > password: > host: localhost > > production: > adapter: mysql > database: mobile_production > timeout: 5000 > username: root > password: > host: localhost > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thank u for ur kind reply.. development: adapter: mysql database: library_development timeout: 5000 username: root password: host: localhost test: adapter: mysql database: library_test timeout: 5000 username: root password: host: localhost production: adapter: mysql database: library_production timeout: 5000 username: root password: its the normal way to connect a data base....how to connect two database or more like this ...any help pls..am a new one to ruby rails.. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jai Jai wrote:> hai...friends.. > how to create multiple mysql database ??pls help > i ve used the following type but it creates only one database > mobile_development..any help pls... > > > development: > adapter: mysql > database: mobile_development > timeout: 5000 > username: root > password: > host: localhost > environment_name1: > adapter: mysql > database: database1 > username: root > password: > host: localhostTheoreticaly you can have every table in its own database, server. class Mytable < ActiveRecord::Base establish_connection(:environment_name1) end or class Mytable2 < ActiveRecord::Base establish_connection( :adapter => "mysql", :host => "localhost", :username => "root", :password => "", :database => "database2" ) set_table_name "anyname" end set_table_name comes wery handy when pluralization is a problem. by TheR -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You might also want to take a look at http://magicmodels.rubyforge.org/magic_multi_connections/ If you''re a newbie, it might be a bit over your head. That will be up to you to decide. I''m using MMC in a rake task right now that will be migrating data from one environment to another. Peace, Phillip -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Theoreticaly you can have every table in its own database, server. > > class Mytable < ActiveRecord::Base > establish_connection(:environment_name1) > endIn my case I have multiple tables in each db so I do something like this: class FinancialConnection < ActiveRecord::Base self.abstract_class = true establish_connection("#{RAILS_ENV}_financials".to_sym) end By doing that I can have a development_financials, test_financials, and production_financials DB and vary the connection for the environment. Further, by making this connection class an abstract ARec class I can use it as the superclass for all the financially related tables: class Account < FinancialConnection end class Journal < FinancialConnection end etc (Note: this relies on the fact that subclasses share the db connection of their superclass if they do not establish one of their own). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---