aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-05-31 15:51:28 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-05-31 15:51:28 -0700
commitf32bceeee1adb0979f49db7e8111ba318e23c85c (patch)
tree56cc30f3e141cf702fcc1512d9d0355a51cc8db4 /railties/lib
parent9b75483bf361f44046d1cb86bd2acae6c4f856f3 (diff)
parent7391f7728d96c2ec0113de57f3316c191043ad2c (diff)
downloadrails-f32bceeee1adb0979f49db7e8111ba318e23c85c.tar.gz
rails-f32bceeee1adb0979f49db7e8111ba318e23c85c.tar.bz2
rails-f32bceeee1adb0979f49db7e8111ba318e23c85c.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/commands/dbconsole.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/railties/lib/commands/dbconsole.rb b/railties/lib/commands/dbconsole.rb
index b81997aa59..17acb7b68f 100644
--- a/railties/lib/commands/dbconsole.rb
+++ b/railties/lib/commands/dbconsole.rb
@@ -2,8 +2,13 @@ require 'erb'
require 'yaml'
require 'optparse'
+include_password = false
+
OptionParser.new do |opt|
- opt.banner = "Usage: dbconsole [environment]"
+ opt.banner = "Usage: dbconsole [options] [environment]"
+ opt.on("-p", "--include-password", "Automatically provide the database from database.yml") do |v|
+ include_password = true
+ end
opt.parse!(ARGV)
abort opt.to_s unless (0..1).include?(ARGV.size)
end
@@ -31,10 +36,13 @@ when "mysql"
'port' => '--port',
'socket' => '--socket',
'username' => '--user',
- 'password' => '--password',
'encoding' => '--default-character-set'
}.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact
+ if config['password'] && include_password
+ args << "--password=#{config['password']}"
+ end
+
args << config['database']
exec(find_cmd('mysql5', 'mysql'), *args)
@@ -43,7 +51,7 @@ when "postgresql"
ENV['PGUSER'] = config["username"] if config["username"]
ENV['PGHOST'] = config["host"] if config["host"]
ENV['PGPORT'] = config["port"].to_s if config["port"]
- ENV['PGPASSWORD'] = config["password"].to_s if config["password"]
+ ENV['PGPASSWORD'] = config["password"].to_s if config["password"] && include_password
exec(find_cmd('psql'), config["database"])
when "sqlite"