Ruby DBI

  • Thread starter Daniel Phillips
  • Start date
D

Daniel Phillips

Hello everyone, this is my first post here.

I've always been interested in Ruby and I'm finally starting to get my
hands dirty.

I'm having trouble getting a script connected to a MySQL database, I've
followed tutorials and downloaded the files from
http://rubyforge.org/projects/ruby-dbi and I ran the three commands to
config, setup and install the DBI.

But in my main ruby script when I require 'dbi' it fails and tells me
that the file couldn't be found, now obviously I can understand that my
script can't see the file I'm telling me to include, but I can't see any
explanation anywhere on which file I'm supposed to include, and some
tutorials have require 'mysql' - so Can anyone tell me what I'm doing
wrong ?

I'm on a UNIX system.
 
D

Daniel Phillips

Daniel said:
Hello everyone, this is my first post here.

I've always been interested in Ruby and I'm finally starting to get my
hands dirty.

I'm having trouble getting a script connected to a MySQL database, I've
followed tutorials and downloaded the files from
http://rubyforge.org/projects/ruby-dbi and I ran the three commands to
config, setup and install the DBI.

But in my main ruby script when I require 'dbi' it fails and tells me
that the file couldn't be found, now obviously I can understand that my
script can't see the file I'm telling me to include, but I can't see any
explanation anywhere on which file I'm supposed to include, and some
tutorials have require 'mysql' - so Can anyone tell me what I'm doing
wrong ?

I'm on a UNIX system.

I have installed the correct module now, and this is the error I am
getting when requiring the 'dbi' module:


/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require': no such file to load -- deprecated (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Site/1.8/dbi.rb:48
from test.rb:5:in `require'
from test.rb:5

What could this mean ?
 
I

Intransition

Hello everyone, this is my first post here.

I've always been interested in Ruby and I'm finally starting to get my
hands dirty.

I'm having trouble getting a script connected to a MySQL database, I've
followed tutorials and downloaded the files fromhttp://rubyforge.org/proj=
ects/ruby-dbiand I ran the three commands to
config, setup and install the DBI.

But in my main ruby script when I require 'dbi' it fails and tells me
that the file couldn't be found, now obviously I can understand that my
script can't see the file I'm telling me to include, but I can't see any
explanation anywhere on which file I'm supposed to include, and some
tutorials have require 'mysql' - so Can anyone tell me what I'm doing
wrong ?

You might want to try:

http://rdbi.hollensbe.org

It is being actively developed. I'm not sure ruby-dbi is any more.
 
B

Brian Candler

Thomas said:
You might want to try:

http://rdbi.hollensbe.org

It is being actively developed. I'm not sure ruby-dbi is any more.

Here are some other options to consider:

1. use the ruby mysql API directly, as described in those tutorials
which had 'require "mysql"'.

dbi is just a layer which sits on top of this, attempting to give a
consistent API to different types of database. So your code would end up
being tied to mysql, but then again, the SQL dialect varies between
databases too.

2. Use a more ruby-flavoured SQL layer such as Sequel.

3. Use a full-blown Object-Relational Mapping layer such as ActiveRecord
or DataMapper.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top