Skip to content

Instantly share code, notes, and snippets.

@wellavelino
Created March 9, 2018 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wellavelino/031c045c971943c4d08f42f228bf3cd5 to your computer and use it in GitHub Desktop.
Save wellavelino/031c045c971943c4d08f42f228bf3cd5 to your computer and use it in GitHub Desktop.
ENV['NLS_LANG'] = 'american_america.utf8'
require 'oci8'
require_relative '../database/querys/query_factory.rb'
require_relative '../../features/support/Helpers.rb'
class ADODataBase
include Helpers
attr_accessor :connection, :username, :password
def initialize(user, pass, connection)
@connection_string = connection
@username = user
@password = pass
end
def open_connection
@connection = OCI8.new(@username, @password, @connection_string)
end
def query(sql)
begin
result_data = @connection.exec(sql)
rescue ConnectionDataBaseException, e
raise 'Something is wrong with database connection', e.message
else
@fields = []
result_data.fetch_hash { |rows| @fields << rows }
ensure
result_data.close
end
@fields
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment