PressingOnAlways PressingOnAlways - 3 months ago 20
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
mysql
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).
    --header
-h, --help                       Show this help message.
-e, --environment=name           Specifies the environment to run this console under (test/development/production).
                                 Default: development