ruby 连接oracle

安装工具oci8

gem install ruby-oci8

 

连接数据库

require 'oci8'

conn = OCI8.new("用户名", "密码", "数据库IP/SID")

 

insert

cursor = conn.exec("insert into table(id,type) values(1,'giftcard')")

conn.commit

 

select

a =[]

cursor = conn.exec('select * from table') { |r| a<<r; }
puts a[0]

#cursor有一些方法也可以输出,比如cursor.fetch

posted on 2014-10-14 12:17  freedomdym  阅读(327)  评论(0编辑  收藏  举报

导航