码迷,mamicode.com
首页 > 数据库 > 详细

ruby 连接oracle

时间:2014-10-14 15:47:48      阅读:360      评论:0      收藏:0      [点我收藏+]

标签:ar   sp   数据   on   bs   new   数据库   type   安装   

安装工具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

ruby 连接oracle

标签:ar   sp   数据   on   bs   new   数据库   type   安装   

原文地址:http://www.cnblogs.com/freedomdym/p/4024139.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!