Last active
December 7, 2021 12:47
-
-
Save alexishida/3caf4e27002329d664321d0e4eb10105 to your computer and use it in GitHub Desktop.
ruby simple oracle dao connector
This file contains hidden or 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
| # frozen_string_literal: true | |
| require 'oci8' | |
| module Connector | |
| class Oracle | |
| def initialize | |
| @con = OCI8.new(ORACLE_CONFIG['user'], ORACLE_CONFIG['password'], ORACLE_CONFIG['host']) | |
| end | |
| def consultar(sql) | |
| cursor = @con.parse(sql) | |
| cursor.exec | |
| return cursor | |
| end | |
| def consulta_retorno(sql) | |
| dados = [] | |
| cursor = @con.parse(sql) | |
| cursor.exec | |
| cursor.fetch do |row| | |
| dados << row | |
| end | |
| return dados | |
| end | |
| def executar(sql) | |
| cursor = @con.parse(sql) | |
| cursor.exec | |
| end | |
| def commit() | |
| @con.commit | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment