Ruby 1.8.7
Rails 2.3.2
script/dbconsoleについて
# config/database.ymlの設定に応じてデータベースに接続する
script/dbconsole
# 接続する環境は選べる
# development環境
script/dbconsole development
# test環境
script/dbconsole test
# production環境
script/dbconsole production
# database.ymlに適当な設定を追加すれば、そこに繋げたりもする
# 普通なそんな用途で使わないとは思いますが、ソース流用する時には使うかも
# database.yml追加分
hoge:
adapter: sqlite3
database: db/hoge.sqlite3
pool: 5
timeout: 5000
# 繋いでみる
script/dbconsole hoge
# リダイレクトでSQLを流すことも可能
# この辺は普通のSQLiteなりMySQLのコマンドと同じ
script/dbconsole hoge < test.sql
script/dbconsole hoge < test.sql > test.out