aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dbshell/postgres_client.rb
blob: b77e6816cfd07ddcb9c61c66c91bfe3d1f29b5df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class DBShell::PostgresClient
  EXECUTABLE_NAME = 'psql'

  def self.build_command(db_info)
    args = [EXECUTABLE_NAME]

    host = db_info['host']
    port = db_info['port']
    db_name = db_info['database']
    user = db_info['username']
    password = db_info['password']

    args.push('-U', user) if user
    args.push('-h', host) if host
    args.push('-p', port) if port
    args.push(db_name)
  end
end