Ruby Forum Ruby on Rails > connecting database with railo

Posted by Mania Suri (manika)
on 28.04.2008 11:16
i m not able to connect to database
I am create my rails folder i get database.yml file in this format
# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  timeout: 5000

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  timeout: 5000
how can i change in the correct format
Posted by Thorsten Mueller (thorsten)
on 28.04.2008 11:20
> i m not able to connect to database

does mean what?
you have a sqlite up and running and it can't connect?
what errors do you get?
did you create the database? what name did you give it?

what OS do you use? maybe you have to install the sqlite3-ruby?

or do you want to use another database, eg mysql?
Posted by Mania Suri (manika)
on 28.04.2008 11:32
I have installed ruby-186-26
I am trying to connect it to  mysql .should I use sqlite as database?how 
can i do it? what should i do ?
Posted by Thorsten Mueller (thorsten)
on 28.04.2008 12:13
Mania Suri wrote:
> I have installed ruby-186-26
> I am trying to connect it to  mysql .should I use sqlite as database?how 
> can i do it? what should i do ?

nope, mysql is fine
sqlite is just the default option, you could use it if you want but 
that's not mandatory (we use mysql here all the time)

use a setup in database.yml like this:

development:
  adapter: mysql
  database: myapp_dev
  username: root
  password:
test:
  adapter: mysql
  database: myapp_test
  username: root
  password:
production:
  adapter: mysql
  database: myapp_production
  username: root
  password:

where myapp_* should match your application name
(and password must be set if you use one)

after that in your application folder run:
rake db:create

that will create the databases in mysql
then you can run

rake db:migrate

to create the tables from your rails migrations if you have defined them 
yet