PressingOnAlways PressingOnAlways - 1 year ago 76
MySQL Question

Passing args to rails dbconsole

rails dbconsole
detects the native DB client and loads it up with all the proper credentials and parameters passed. Is there a way to pass additional parameters to the DB client?

For instance, if you're using mysql, it will load up
client. I'd like to be able to pass arguments such as
mysql -e 'SELECT NOW();'
or whatever custom query I would like.

Answer Source

No, what you're asking is not possible. You can pass some options though, check

$ rails dbconsole -h
Usage: rails dbconsole [environment] [options]
-p, --include-password           Automatically provide the password from database.yml
    --mode [MODE]                Automatically put the sqlite3 database in the specified mode (html, list, line, column).
-h, --help                       Show this help message.
-e, --environment=name           Specifies the environment to run this console under (test/development/production).
                                 Default: development
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download