diff options
author | Teddy Wing | 2017-04-29 22:49:10 +0200 |
---|---|---|
committer | Teddy Wing | 2017-04-29 22:49:10 +0200 |
commit | 575141e4efc770a4207eb5d905819d4017731f65 (patch) | |
tree | ccd831bf10830d20cf348042b1e1ce244e9d4d9e /lib | |
parent | 3c5729137d4ea81c607bfc9422ceaeb1056081c5 (diff) | |
download | dbshell-rails-575141e4efc770a4207eb5d905819d4017731f65.tar.bz2 |
Add `DBShell::Client::MySQL`
For now only includes a `.build_command()` method.
Inspired again by:
https://github.com/django/django/blob/66150f7cf61bc09547fa98586790df596eff6d77/django/db/backends/mysql/client.py
although in our case we haven't handled some of the more exotic options.
Eventually we'll probably have to do that.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dbshell/client/mysql.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/dbshell/client/mysql.rb b/lib/dbshell/client/mysql.rb new file mode 100644 index 0000000..6cb8233 --- /dev/null +++ b/lib/dbshell/client/mysql.rb @@ -0,0 +1,23 @@ +module DBShell + module Client + class MySQL + EXECUTABLE_NAME = 'mysql' + + 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("--user=#{user}") if user + args.push("--password=#{password}") if password + args.push("--host=#{host}") if host + args.push("--port=#{port}") if port + args.push(db_name) + end + end + end +end |