Need help for Ruby DBI and PostgreSQl

M

Manisha Tripathy

Hi,

I am trying to access aPostgreSQL database from a Ruby program.
I have the Linux(Ubuntu) OS, database server running and Ruby installed
well.
I have the gems postgres-pr. I downloaded rubu-dbi package manually and
installed it.I installed dbi using the following steps:

ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

But the only problem during installation was that I couldnt do config
with option
i.e.

ruby setup.rb config --with=dbi,dbd_pg

It showed error while using that option.

now its ok when i do:

require 'postgres'

but for require 'dbi' it shows false.

I dont understand what to do.Its all badly messed up.
Can Anyone please provide some guidance in this regards?
 
M

Manisha Tripathy

Mikel said:
require returns false when the library has already been loaded.

Just try and see if it works.

Thanks Mikel,

but the problem is that i cannot connect to the database server as i
cannot do

dbh = DBI.connect('DBI:pg:databasename')
 
S

Simon Krahnke

* Manisha Tripathy said:
Thanks Mikel,

but the problem is that i cannot connect to the database server as i
cannot do

dbh = DBI.connect('DBI:pg:databasename')

That's strange. Maybe the keyboard on that computer is broken. Try
copying it over.

mfg, simon .... nth
 
B

Brian Candler

Manisha said:
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

But the only problem during installation was that I couldnt do config
with option
i.e.

ruby setup.rb config --with=dbi,dbd_pg

It showed error while using that option.

You need to show the exact error message you got.

As it is, we can only guess - maybe you forgot to install the libpq-dev
package first? If you'd shown the error message, we could tell you for
sure.

Similarly, if

require 'postgres'
dbh = DBI.connect('DBI:pg:databasename')

is giving an error, then you need to show the exact error. "I cannot
connect" isn't helpful.
 
M

Manisha Tripathy

Brian said:
You need to show the exact error message you got.

As it is, we can only guess - maybe you forgot to install the libpq-dev
package first? If you'd shown the error message, we could tell you for
sure.

Similarly, if

require 'postgres'
dbh = DBI.connect('DBI:pg:databasename')

is giving an error, then you need to show the exact error. "I cannot
connect" isn't helpful.


ok, here is the error :

config: unknown option --with=dbi,dbd_pg
Try 'ruby setup.rb --help' for detailed usage.

When i checked for help, it just doesnt have an option --with= , but in
all the tutorials for ruby-dbi, i found the same.I already have
installed libpq-dev package.
I am quite a beginner, so may be i am missing something fundamental.It
will be very kind if anyone can help.i will be glad to learn.
 
B

Brian Candler

Manisha said:
ok, here is the error :

config: unknown option --with=dbi,dbd_pg
Try 'ruby setup.rb --help' for detailed usage.

You didn't show the command line you typed. But the following works just
fine for me:

$ ruby setup.rb config --with=dbi,dbd_pg
entering config phase...
config done.

This is dbi-0.2.0, ruby-1.8.6p111, Ubuntu Hardy. And I just took this
command from the README file.
When i checked for help, it just doesnt have an option --with=

It does for me.

$ ruby setup.rb config --help
config: unknown option --help
try "ruby setup.rb --help" for usage

$ ruby setup.rb --help

Usage:
...
Options for config:
...
--with=name,name... package name(s) you want to install [ALL]
--without=name,name... package name(s) you do not want to install []

So in this case maybe it's a good idea to list the exact platform,
version of Ruby, version of ruby-dbi you have unpacked, and to
copy-paste both the command you have typed *and* the responses you get.

Regards,

Brian.
 
M

Manisha Tripathy

Brian said:
Manisha said:
ok, here is the error :

config: unknown option --with=dbi,dbd_pg
Try 'ruby setup.rb --help' for detailed usage.

You didn't show the command line you typed. But the following works just
fine for me:

$ ruby setup.rb config --with=dbi,dbd_pg
entering config phase...
config done.

This is dbi-0.2.0, ruby-1.8.6p111, Ubuntu Hardy. And I just took this
command from the README file.
When i checked for help, it just doesnt have an option --with=

It does for me.

$ ruby setup.rb config --help
config: unknown option --help
try "ruby setup.rb --help" for usage

$ ruby setup.rb --help

Usage:
...
Options for config:
...
--with=name,name... package name(s) you want to install [ALL]
--without=name,name... package name(s) you do not want to install []

So in this case maybe it's a good idea to list the exact platform,
version of Ruby, version of ruby-dbi you have unpacked, and to
copy-paste both the command you have typed *and* the responses you get.

Regards,

Brian.

Thanks Brian.

But the same doesnt work for me i.e.
$ ruby setup.rb config --with=dbi,dbd_pg

But however, i was so messed up that, now i removed the installation i
did manually. I installed pg, dbi and dbd-pg gems using $ gem
install.........

Then tried the Ruby program i wrote again, and the wonder is that it
worked!!
I can connect to the PostgreSQL database from the Ruby program with
statement

dbh = DBI.connect('DBI:pg:database_name','username','password')

Honestly speaking I dont understand completely the reason,but it
works.If you can explain it, I will be thankful.
 
B

Brian Candler

Manisha said:
Honestly speaking I dont understand completely the reason,but it
works.If you can explain it, I will be thankful.

I can't do that, since you still haven't shown:

* your operating system version, your ruby version, and the dbi version
you're trying to install

* the exact commands you typed *together with* the responses that came
back

In particular, you say that the output of "ruby setup.rb --help" didn't
list the --with option, but you can see from the output I posted that it
did for me.

So if you showed the actual output you got, it might explain why.
Perhaps we're either running different versions of setup.rb, or
different versions of ruby, but that's just a guess.
 
M

Manisha Tripathy

Brian said:
I can't do that, since you still haven't shown:

* your operating system version, your ruby version, and the dbi version
you're trying to install

* the exact commands you typed *together with* the responses that came
back

In particular, you say that the output of "ruby setup.rb --help" didn't
list the --with option, but you can see from the output I posted that it
did for me.

So if you showed the actual output you got, it might explain why.
Perhaps we're either running different versions of setup.rb, or
different versions of ruby, but that's just a guess.


Hi, here is some information, hope it can help you to understand the
problem.

Operating system is : Ubuntu 8.0.4
Ruby version : 1.8.6
DBI that i am trying to install is : dbi-0.4.1

the commands and responses are:

1. root@manisha-desktop:/home/manisha/dbi-0.4.1# ruby setup.rb config
--with=dbi,dbd_pg


config: unknown option --with=dbi,dbd_pg

Try 'ruby setup.rb --help' for detailed usage.


2. root@manisha-desktop:/home/manisha/dbi-0.4.1# ruby setup.rb --help

Typical Installation Procedure:
$ ruby setup.rb config
$ ruby setup.rb setup
# ruby setup.rb install (may require root privilege)

Detailed Usage:
ruby setup.rb <global option>
ruby setup.rb [<global options>] <task> [<task options>]

Global options:
-q,--quiet suppress message outputs
--verbose output messages verbosely
--help print this message
--version print version and quit
--copyright print copyright and quit

Tasks:
all do config, setup, then install
config saves your configurations
show shows current configuration
setup compiles ruby extentions and others
install installs files
test run all tests in test/
clean does `make clean' for each extention
distclean does `make distclean' for each extention

Options for CONFIG or ALL:
--installdirs=std/site/home std: install under libruby; site: install
under site_ruby; home: install under $HOME []
--prefix=path path prefix of target environment [/usr]
--bindir=path the directory for commands [$prefix/bin]
--libdir=path the directory for libraries [$prefix/lib]
--datadir=path the directory for shared data [$prefix/share]
--mandir=path the directory for man pages
[$prefix/share/man]
--sysconfdir=path the directory for system configuration files
[/etc]
--localstatedir=path the directory for local state data [/var]
--libruby=path the directory for ruby libraries
[/usr/lib/ruby]
--librubyver=path the directory for standard ruby libraries
[/usr/lib/ruby/1.8]
--librubyverarch=path the directory for standard ruby extensions
[/usr/lib/ruby/1.8/i486-linux]
--siteruby=path the directory for version-independent aux
ruby libraries [/usr/local/lib/site_ruby]
--siterubyver=path the directory for aux ruby libraries
[/usr/local/lib/site_ruby/1.8]
--siterubyverarch=path the directory for aux ruby binaries
[/usr/local/lib/site_ruby/1.8/i486-linux]
--rbdir=path the directory for ruby scripts [$siterubyver]
--sodir=path the directory for ruby extentions
[$siterubyverarch]
--rubypath=path the path to set to #! line [/usr/bin/ruby1.8]
--rubyprog=name the ruby program using for installation
[/usr/bin/ruby1.8]
--makeprog=name the make program to compile ruby extentions
[make]
--shebang=all/ruby/never shebang line (#!) editing mode [ruby]
--without-ext does not compile/install ruby extentions [no]
--rbconfig=path rbconfig.rb to load [running ruby's]

Options for INSTALL:
--no-harm only display what to do if given [off]
--prefix=path install path prefix []
 
B

Brian Candler

Manisha said:
Hi, here is some information, hope it can help you to understand the
problem.

Operating system is : Ubuntu 8.0.4
Ruby version : 1.8.6
DBI that i am trying to install is : dbi-0.4.1

Thank you. The problem is simply that you were following information on
the web which was written for an older version of dbi.

dbi-0.2.0 has all the dbd's bundled in with it. It seems that they have
now been separated out into separate packages. As a result, the
--with-dbd option has been removed; you choose which dbd's you want by
installing the relevant dbd packages.

Regards,

Brian.
 
M

Manisha Tripathy

Brian said:
Thank you. The problem is simply that you were following information on
the web which was written for an older version of dbi.

dbi-0.2.0 has all the dbd's bundled in with it. It seems that they have
now been separated out into separate packages. As a result, the
--with-dbd option has been removed; you choose which dbd's you want by
installing the relevant dbd packages.

Regards,

Brian.

Thanks Brian, for all the information.
I have a doubt, may be its simple but i have some confusion.
I installed everything as gems , like dbi, dbd-pg, dbd-mysql, pg and
postgres.
Everything working fine now. Is installing gem the same like it would
have been if we install the packages manually?
 
B

Brian Candler

I have a doubt, may be its simple but i have some confusion.
I installed everything as gems , like dbi, dbd-pg, dbd-mysql, pg and
postgres.
Everything working fine now. Is installing gem the same like it would
have been if we install the packages manually?

Perhaps in different locations, but otherwise it should all work the
same. Gems are the preferred installation mechanism if the package
provides one.
 
M

Manisha Tripathy

Brian said:
Perhaps in different locations, but otherwise it should all work the
same. Gems are the preferred installation mechanism if the package
provides one.

thanks a lot for the information
 

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

how to uninstall ruby-dbi-all 0
Ruby DBI 3
installing ruby-dbi for mysql 2
Ruby DBI problem 0
Using DBI and MySQL gems 13
Ruby DBI Help Needed 0
dbi mysql support ... 1
DBI and SQLite3 1

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top