Class: Load

Inherits:
Object
  • Object
show all
Defined in:
lib/setl_tool/load.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db_host, db_name, db_user, db_passwd) ⇒ Load

Returns a new instance of Load.



25
26
27
28
29
30
31
# File 'lib/setl_tool/load.rb', line 25

def initialize(db_host, db_name, db_user, db_passwd)
  @conn = PG.connect(host: db_host,
                     dbname: db_name,
                     user: db_user,
                     password: db_passwd)
  @conn.set_error_verbosity(PG::PQERRORS_VERBOSE)
end

Instance Attribute Details

#connObject

Returns the value of attribute conn.



23
24
25
# File 'lib/setl_tool/load.rb', line 23

def conn
  @conn
end

#db_hostObject

Returns the value of attribute db_host.



19
20
21
# File 'lib/setl_tool/load.rb', line 19

def db_host
  @db_host
end

#db_nameObject

Returns the value of attribute db_name.



20
21
22
# File 'lib/setl_tool/load.rb', line 20

def db_name
  @db_name
end

#db_passwdObject

Returns the value of attribute db_passwd.



22
23
24
# File 'lib/setl_tool/load.rb', line 22

def db_passwd
  @db_passwd
end

#db_userObject

Returns the value of attribute db_user.



21
22
23
# File 'lib/setl_tool/load.rb', line 21

def db_user
  @db_user
end

Instance Method Details

#insert(stmt) ⇒ Object



33
34
35
# File 'lib/setl_tool/load.rb', line 33

def insert(stmt)
  @conn.exec(stmt)
end