Class: Kandata::Database

Inherits:
Mysql2::Client
  • Object
show all
Defined in:
lib/kandata/database.rb,
lib/kandata/database/connection_info.rb

Overview

ActiveRecordを使わないでKandataデータベースにアクセスするためのクラス ignore :reek:InstanceVariableAssumption:

Defined Under Namespace

Classes: ConnectionInfo

Instance Method Summary collapse

Constructor Details

#initializeDatabase

Returns a new instance of Database.



8
9
10
11
12
13
14
15
16
# File 'lib/kandata/database.rb', line 8

def initialize
  create_database_if_not_exists
  super(
    Kandata::Database::ConnectionInfo.host_and_user.merge(
      database: Kandata::Database::ConnectionInfo.database_name,
      local_infile: true
    )
  )
end

Instance Method Details

#load_tsv(filename, force_update, headers = nil) ⇒ Object

ignore :reek:ControlParameter:



19
20
21
22
23
24
25
26
27
# File 'lib/kandata/database.rb', line 19

def load_tsv(filename, force_update, headers = nil)
  @tsv = Kandata::TsvFile.new(filename, headers)

  drop_table if force_update
  create_table
  load_data

  full_table_name
end