Reputation: 12356
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.
Upvotes: 4
Views: 2555
Reputation: 1082
What you're asking is not perfectly possible!
echo -e "SELECT NOW();\n" | rails dbconsole
Upvotes: 4
Reputation: 2005
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
Upvotes: 6