blob: 78b82d702926a90ce02d2e387bf817985757c463 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
module DBShell
module Client
class Postgres
EXECUTABLE_NAME = 'psql'
def self.runshell(db_info)
args = self.build_command(db_info)
exec(*args)
end
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.to_s) if port
args.push(db_name)
end
end
end
end
|