将参数传递给rails dbconsole

Pre*_*ays 4 mysql ruby-on-rails ruby-on-rails-4

rails dbconsole检测本机数据库客户端并使用传递的所有正确凭据和参数加载它。有没有办法将附加参数传递给数据库客户端?

例如,如果您使用 mysql,它将加载mysql客户端。我希望能够传递参数,例如mysql -e 'SELECT NOW();'我想要的自定义查询。

nik*_*ypx 6

不,你问的是不可能的。不过你可以传递一些选项,检查

$ 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
Run Code Online (Sandbox Code Playgroud)