【问题标题】:How to pass CLI options to heroku pg:psql?如何将 CLI 选项传递给 heroku pg:psql?
【发布时间】:2014-04-14 14:50:51
【问题描述】:
  • 鉴于 heroku pg:psql 工作,连接到数据库
  • 并且 $SQL 是一个有效的 SQL 查询
  • 我运行heroku pg:psql -c $SQL
  • 那么我希望看到查询结果
  • 并且我希望heroku 退出并显示0 的状态码

相反,-c 选项被忽略,$SQL执行,并显示交互式提示。

【问题讨论】:

    标签: heroku psql


    【解决方案1】:

    看起来像一个错误,对此感到抱歉:-/

    我已经举报了。

    看来pg:extras 可能是罪魁祸首,如果你没有它,它可能会起作用。见here

    试试

    heroku plugins:uninstall heroku-pg-extras
    

    有一个解决方法 - 将命令输入:

    <<< "select count(*) from features;" | heroku pg:psql -a appname -c -
    

    【讨论】:

    • 感谢 Jon,两种解决方法都成功了。不过,&lt;&lt;&lt; 是什么?我在管道的前半部分使用了echo
    • 嘿。这些被称为Here Documents。它们允许您使用分隔符来指定要读取的文本,然后作为标准输入发送。
    猜你喜欢
    • 2021-11-15
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-20
    • 2012-12-17
    相关资源
    最近更新 更多