Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 将参数传递到rails数据库控制台_Mysql_Ruby On Rails_Ruby On Rails 4 - Fatal编程技术网

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。:)