From: Yasushi Shoji Date: 2000-09-23T07:05:40+09:00 Subject: [ruby-talk:5075] Re: RDBMS interface for Ruby? At Sat, 23 Sep 2000 04:40:02 +0900, philipd9@my-deja.com wrote: > > Has anyone written an interface to the more common relational database > systems? I am thinking of something similar to Perl's DBI + DBD::Oracle. > > I know I can just open a pipe to sqlplus, but that is no better than > using the Korn shell! i thought that, too. but someone told me that Ruby doesn't even need interface library if all DBD has same protocol(method names). # i don't know how well thouse dbd is organized, though... ;p it's been a while since i checked Perl's DBI, so I might be wrong here. but, even you are usign DBI, you gotta have DBD access for some specific functions, right? under Ruby, because you have to specify the database you want, creating an instance of db object gotta be a DBD specific task. but, once you got a db object you can treate them all same. btw, library for oracle is already out there. check RAA. -- yashi # it will NOT work. def DBI.new(:database, *arg) case when :oracle require 'oracle' Oracle.connect(arg) when :postgres require 'postgres Postgres.connect(what, ever, you, need) when :mysql require 'mysql' Mysql.connect(arg) end end db = DBI.new(:oracle, localhost, user, pass) db.sql('select ....') # hmm... still worth having DBI?