您的位置:首页 > 博客中心 > 数据库 >

ruby 连接oracle

时间:2022-03-14 01:00

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

热门排行

今日推荐

热门手游