I\'m writing a rake task that does some DB work outside of Rails/ActiveRecord.
Is there a way to get the DB connection info (host, username, password, DB name) for t
ActiveRecord::Base.connection_config
returns the connection configuration in a hash:
=> {:adapter=>ADAPTER_NAME, :host=>HOST, :port=>PORT,
:database=>DB, :pool=>POOL, :username=>USERNAME,
:password=>PASSWORD}
As tpett remarked in their comment: this solution accounts for merging the configuration from database.yml and from the environment variable DATABASE_URL.