aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTeddy Wing2017-04-29 19:02:02 +0200
committerTeddy Wing2017-04-29 19:15:46 +0200
commitbb26c6d3a4f96a8e87cf14bb72ef283c86e8891a (patch)
tree527526a2e1717567197635c88297b01599274e09 /lib
parente89275bc787ae17bc698ac8cdb8cdaf5ebeb7852 (diff)
downloaddbshell-rails-bb26c6d3a4f96a8e87cf14bb72ef283c86e8891a.tar.bz2
PostgresClient: Basic implementation of #build_command
Correctly builds the required arguments. Doesn't handle passwords at all.
Diffstat (limited to 'lib')
-rw-r--r--lib/dbshell/postgres_client.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/dbshell/postgres_client.rb b/lib/dbshell/postgres_client.rb
index a22ccf7..b77e681 100644
--- a/lib/dbshell/postgres_client.rb
+++ b/lib/dbshell/postgres_client.rb
@@ -1,4 +1,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