aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dbshell/client/database.rb
blob: b6be74bad1761f4afd035722a88ddb9c17548918 (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
28
29
30
31
require 'dbshell/client/sqlite3'
require 'dbshell/client/postgres'
require 'dbshell/client/mysql'

module DBShell
  module Client
    class Database
      def self.handler(connection_params)
        case connection_params['adapter']
        when 'sqlite3'
          DBShell::Client::SQLite3
        when 'postgresql'
          DBShell::Client::Postgres
        when 'mysql2'
          DBShell::Client::MySQL
        else
          raise UnsupportedDatabaseAdapter
        end
      end

      def self.runshell(connection_params)
        self
          .handler(connection_params)
          .runshell(connection_params)
      end
    end


    class UnsupportedDatabaseAdapter < StandardError; end
  end
end