Created
March 9, 2018 01:17
-
-
Save wellavelino/031c045c971943c4d08f42f228bf3cd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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