Can we put any number of databases in YML file?

Hello

By default, RubyOnRails let you have 3 databases, development, test and
production.
Can we add more databases in this file? Is there any limitation?

Example
--------------------------------------- START
% cat config/database.yml
development:
adapter: mysql
database: rails_development
host: localhost
username: davis
password: hogehero

test:
adapter: mysql
database: rails_test
host: localhost
username: davis
password: hogehero

production:
adapter: mysql
database: rails_production
host: localhost
username: davis
password: hogehero

production1:
adapter: mysql
database: rails_production1
host: localhost
username: davis
password: hogehero

production2:
adapter: mysql
database: rails_production2
host: localhost
username: davis
password: hogehero

--------------------------------------- END

Have anyone added more databases?
Please let me know how did it go.

Thank you!

Eriko Uchi wrote:

By default, RubyOnRails let you have 3 databases, development, test and
production.
Can we add more databases in this file? Is there any limitation?

Can we change RAILS_ENV to ‘beatlemania’, add a matching item to the
config/environment folder and the database.yml file?

Under Rails, I suspect the answer is yes, because Convention over
Configuration allows the system to minimize all its configuration
systems. But I suspect nobody ever needed to do this.

You are not asking for a new concept, beyond the natural trinity of
test, develop, and produce. You are just asking for alternate
databases. Toke some eRB:

production:
adapter: mysql
database: rails_production

database: <%= ENV[‘RAILS_DB’] %>

Now set that environmental variable (in the environment, or in
config/boot.rb if you can’t access the environment).


Phlip
http://www.oreilly.com/catalog/9780596510657/
^ assert_xpath
http://tinyurl.com/yrc77g <-- assert_latest Model

Another way of using database.yml (separate from environments) is to
store separate connections that may only be used by a few models in an
application. You can specify all of the database details in
database.yml, then connect to them in your model i.e.

some_other_db:
adapter: mysql
database: anotherdatabase
username: dbuser
host: someotherhost

Then in the models that will use this connection:

establish_connection :some_other_db

I have used this a few times and it works well. It has the benefit of
keeping all db connection information in one place rather than
specifying it directly in establish_connection.

(See Agile page 293)

[email protected] wrote:


Sincerely,

William P.

http://www.billpratt.net
[email protected]

Hi –

On Thu, 16 Aug 2007, Eriko Uchi wrote:

Hello

By default, RubyOnRails let you have 3 databases, development, test and
production.
Can we add more databases in this file? Is there any limitation?

What you’re really doing is creating (or implying) new environments.
If you add a file production1.rb to config/environments (look at the
ones there for examples) and add your production1 stanza to
database.yml, you can then run in a new environment:

./script/server -e production1

David