View on GitHub


Run single sql statements against an Oracle schema

Download this project as a .zip file Download this project as a tar.gz file

This gem is a thin wrapper around the ruby-oci8 gem. The client is intended to be used by simple scripts to aid automation. The code is intentionally light-weight and featureless, with very little startup time.

It is not meant to be a Ruby ORM for Oracle - if you want that, look at the OracleEnhancedAdapter.


Before installing, you must have Oracle Instantclient installed on your machine. See for details.

$ gem install oci8_simple

oci8_simple uses the same database configuration file format that ActiveRecord uses. It will look in the following places for the configuration file, in order:

Dir.pwd + "/database.yml"
Dir.pwd + "/config/database.yml"

As an example, this database.yml defines the 'development' and 'test' schema connections:

  username: rash_doctor
  password: N33dlez

  username: skin_doctor
  password: N33dlez

Shell helpers

Oci8Simple installs several shell scripts. Each script takes an optional parameter to specify which database to connect to. Database configuration is pulled from ~/oci8_simple/database.yml. If no database is specified, Oci8Simple uses "development."


run arbitrary SQL

$ oci8_simple 'select id, name from rashes'
214381688, Psoriasis
1418205031, Dermatitis
2104832561, Chicken Pox
1600313148, Impetigo


describe a table

$ describe rashes
Required  Name             Type      Size    Char?  Char_size  Precision  Scale  Default   
          description      clob                                                            
       *  id               number    22.0                      38.0       0.0              
          oozing_pus       number    22.0                      1.0        0.0    1         
          name             varchar2  1020.0  *      255.0                                  
          itchy            number    22.0                      1.0        0.0    0         


list things in the database (tables, views, etc.)

$ show tables

Ruby code

You can also use oci8_simple in your Ruby scripts by creating an instance of Oci8Simple::Client.

require 'rubygems'
require 'oci8_simple'

# connect to the "test" database defined in ~/.oci8_simple/database.yml
client ="test")  
# please oh god make the pain stop"select id, name from rashes")

# [[214381688, "Psoriasis"], 
#  [1418205031, "Dermatitis"], 
#  [2104832561, "Chicken Pox"], 
#  [1600313148, "Impetigo"]]