oracle_raw 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -6
- data/LICENSE.txt +159 -670
- data/README.md +93 -0
- data/Rakefile +2 -10
- data/VERSION +1 -1
- data/lib/oracle_raw.rb +37 -87
- data/test/test_oracle_raw.rb +28 -3
- metadata +90 -79
- data/README.rdoc +0 -55
data/README.rdoc
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
= oracle_raw
|
2
|
-
|
3
|
-
This is a library for interfacing with an Oracle Database. It uses ActiveRecord Oracle Enhanced adapter (https://github.com/rsim/oracle-enhanced) for connection pooling, but otherwise a raw Ruby-OCI8 connection (http://ruby-oci8.rubyforge.org/en/) is used.
|
4
|
-
|
5
|
-
At the moment the following methods are implemented:
|
6
|
-
|
7
|
-
- a general querying method
|
8
|
-
- a _with_connection_ method, that takes a block as an argument. inside the block you can use a raw OCI8 connection object to execute queries, updates etc.
|
9
|
-
|
10
|
-
Tests are not comprehensive at the moment.
|
11
|
-
|
12
|
-
== Installation:
|
13
|
-
|
14
|
-
gem install oracle_raw
|
15
|
-
|
16
|
-
== Usage:
|
17
|
-
|
18
|
-
tnsnames = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = TEST)))'
|
19
|
-
schema = 'scott'
|
20
|
-
password = 'tiger'
|
21
|
-
connection_pool_size = 5
|
22
|
-
|
23
|
-
db = OracleDB.new(tnsnames, schema, password, connection_pool_size)
|
24
|
-
db.with_connection { |c|
|
25
|
-
c.exec('create table students (first_name varchar2(20), last_name varchar2(20), age number, address varchar2(20), city varchar2(20))')
|
26
|
-
c.exec("insert into students (first_name, last_name, age, address, city) values ('Lucy', 'Kruskal-Wallis', 30, null, null)")
|
27
|
-
c.commit
|
28
|
-
}
|
29
|
-
|
30
|
-
result = db.query('select sysdate from dual', nil, {:item_format => :array, :amount => :single_value})
|
31
|
-
puts result[:data].class # => Time
|
32
|
-
|
33
|
-
students_sql = 'select * from students where last_name = :last_name and first_name = :first_name'
|
34
|
-
result = db.query(students_sql, [[:last_name, 'Kruskal-Wallis', String], [:first_name, 'Lucy', String]],
|
35
|
-
{:item_format => :hash, :amount => :first_row, :metadata => :all})
|
36
|
-
puts result[:columns] # => ['first_name', 'last_name', 'age', 'address', 'city']
|
37
|
-
puts result[:data]['FIRST_NAME'] # => 'Lucy'
|
38
|
-
|
39
|
-
db.close
|
40
|
-
|
41
|
-
== Contributing to ruby_oracle_interface
|
42
|
-
|
43
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
44
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
45
|
-
* Fork the project
|
46
|
-
* Start a feature/bugfix branch
|
47
|
-
* Commit and push until you are happy with your contribution
|
48
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
49
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
50
|
-
|
51
|
-
== Copyright
|
52
|
-
|
53
|
-
Copyright (c) 2011 opiskelijarekisteri-devel. See LICENSE.txt for
|
54
|
-
further details.
|
55
|
-
|