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
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
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…
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
Theoreticaly you can have every table in its own database, server.
class Mytable < ActiveRecord::Base
establish_connection(:environment_name1)
end
In 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).
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: localhost
Theoreticaly 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