安装工具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
时间: 2024-10-14 04:56:41