Skip to content

Instantly share code, notes, and snippets.

@pvh
Created July 15, 2010 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pvh/477404 to your computer and use it in GitHub Desktop.
Save pvh/477404 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
u = URI.parse(ARGV[0])
u.scheme == "postgres" or abort("Must provide a postgres://user:pass@host/dbname form url.")
ENV["PGPASSWORD"] = u.password
cmd = "psql -U #{u.user} -h #{u.host} #{u.path[1..-1]}"
puts cmd
exec cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment