aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dbshell/client/database.rb
blob: 86cbfeff3352474bd4c39c035b259383903611bd (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
require 'dbshell/client/sqlite3'
require 'dbshell/client/postgres'

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
        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