Class: Connection

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

Overview

Establish connection to mysql2

Instance Method Summary collapse

Instance Method Details

#closeObject



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

def close
  @connection.close
end

#openObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/connection.rb', line 4

def open
  # Read the database credentials from local file
  creds = YAML.load_file(File.expand_path('~/.wolas/credentials.yml'))

  @connection = Mysql2::Client.new(
    :database => creds['channel_service']['database'],
    :host => creds['channel_service']['host'], 
    :username => creds['channel_service']['username'],
    :password => creds['channel_service']['password'],
    :connect_timeout => 20
  )
end

#prepare(code) ⇒ Object



17
18
19
20
# File 'lib/connection.rb', line 17

def prepare(code)
  result = @connection.prepare(code)
  return result
end