Mysql 将参数传递到rails数据库控制台
Mysql 将参数传递到rails数据库控制台,mysql,ruby-on-rails,ruby-on-rails-4,Mysql,Ruby On Rails,Ruby On Rails 4,railsdbconsole检测本机数据库客户机,并使用传递的所有正确凭据和参数将其加载。是否有方法将其他参数传递给DB客户端 例如,如果您使用的是mysql,它将加载mysqlclient。我希望能够传递参数,例如mysql-e'SELECT NOW();'或任何我想要的自定义查询。不,您所要求的是不可能的。不过,您可以传递一些选项,请检查 $ rails dbconsole -h Usage: rails dbconsole [environment] [options] -p, --inc
railsdbconsole
检测本机数据库客户机,并使用传递的所有正确凭据和参数将其加载。是否有方法将其他参数传递给DB客户端
例如,如果您使用的是mysql,它将加载
mysql
client。我希望能够传递参数,例如mysql-e'SELECT NOW();'代码>或任何我想要的自定义查询。不,您所要求的是不可能的。不过,您可以传递一些选项,请检查
$ 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
你所要求的不是完全可能的
echo -e "SELECT NOW();\n" | rails dbconsole
希望这不会在几个月/几年内成为答案。看起来我需要向项目提交一份PR。:)