# File lib/heroku/command/pg.rb, line 150
    def psql
      with_psql_binary do
        with_heroku_postgresql_database do |name, url|
          database = heroku_postgresql_client(url).get_database
          abort " !  The database is not available" unless database[:state] == "available"
          display("Connecting to database for app #{app} ...")
          heroku_postgresql_client(url).ingress
          url = URI.parse(url)
          ENV["PGPASSWORD"] = url.password
          cmd = "psql -U #{url.user} -h #{url.host} #{url.path[1..-1]}"
          system(cmd)
        end
      end
    end