Rails 2.0.2 Uses SQLite3 by Default?
Monday, January 21st, 2008I just upgraded to Rails 2.0.2 by running:
$gem update rails
I started my new Rails project. The content of config/database.yml surprised me!
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
I used Google to search for the change and found Rob’s post.
Here I am using MAMP as my MYSQL database provider so far. So, I have to try it out. ![]()
I quickly whipped up a test project and created a new model.
$rails test
$ruby script/generate model product
I modified db/migrate/001_create_products.rb to add one column only:
create_table :products do |t|
t.column :name, :string
end
Finally…
$rake db:migrate
== CreateProducts: migrating ==================================================
– create_table(:products)
-> 0.0033s
== CreateProducts: migrated (0.0035s) =========================================
The first thing that came to my mind is “SWEET!!!” ![]()
Although Mac has SQLite3 by default, Windows users may not. The good news is that Rob also has the solution.
I think this is a good news for users that have sqlite3 installed by default because there is one less thing to setup. Also, using SQLite3 makes the development directory more compartmentalized.
After playing around with the database a little bit, I don’t like how data is shown in the query. Each field is delimited by a pipe character.
$sqlite3 db/development.sqlite3
sqlite> select * from products;
1|Test Product
I can’t seem to find a Mac-based tools to maintain SQLite3 database. Also, I don’t want to install/configure web-based tools if one is available.
I’ve decided that I’m going to stay with MYSQL for now due to more mature tools (that I can use to view my MYSQL database).
rails -d mysql myapp