 |
Forums |
Admin Start New Thread
By: Robert Stagner
RE: DBI :: Postgresql not working on windows [ reply ] 2008-05-13 20:31
|
Have you been provided a solution for your 'load_driver: Could not load driver...' error?
I'm encountering the same error, except for an instance on MySQL on Windows. Here is what I'm seeing:
Available drivers = dbi:Proxy:,dbi:Pg:,dbi:ODBC:,dbi:Mysql:
c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:368:in `load_driver': Could not load driver (no such file to load -- c:/ruby/lib/ruby/site_ruby/1.8/dbd/Mysql)
|
By: Salvatore Quercia
RE: DBI :: Postgresql not working on windows [ reply ] 2008-04-01 12:07
|
Hi Erik,
Thanks for your quick reply.
You'll notice in the gems list below I've ruby-postgres (0.7.1.2005.12.21)and postgres-pr (0.4.0).
This is my complete list of locallly installed gems:
C:\download\ruby-pg>gem list --local
*** LOCAL GEMS ***
actionmailer (2.0.2)
Service layer for easy email delivery and testing.
actionpack (2.0.2)
Web-flow and rendering framework putting the VC in MVC.
activerecord (2.0.2)
Implements the ActiveRecord pattern for ORM.
ActiveRecord-JDBC (0.5)
JDBC adapter for ActiveRecord, for use within JRuby on Rails.
activeresource (2.0.2)
Think Active Record for web resources.
activesupport (2.0.2)
Support and utility classes used by the Rails framework.
dbi-dbrc (1.1.1)
A simple way to avoid hard-coding passwords with DBI
fxri (0.3.6)
Graphical interface to the RI documentation, with search engine.
fxruby (1.6.13, 1.6.6)
FXRuby is the Ruby binding to the FOX GUI toolkit.
hpricot (0.6, 0.4)
a swift, liberal HTML parser with a fantastic library
jdbc-postgres (8.2)
PostgreSQL JDBC driver for Java and PostgreSQL/ActiveRecord-JDBC.
log4r (1.0.5)
Log4r is a comprehensive and flexible logging library for Ruby.
mysql (2.7.3)
A win32-native build of the MySQL API module
for Ruby.
postgres-pr (0.4.0)
A pure Ruby interface to the PostgreSQL (>= 7.4) database
rails (2.0.2)
Web-application framework with template engine, control-flow layer,
and ORM.
rake (0.8.1, 0.7.2)
Ruby based make-like utility.
ruby-debug-base (0.10.0)
Fast Ruby debugger - core component
ruby-debug-ide (0.1.10)
IDE interface for ruby-debug.
ruby-postgres (0.7.1.2005.12.21)
Ruby extension library providing an API to PostgreSQL
sources (0.0.1)
This package provides download sources for remote gem installation
win32-api (1.0.5)
A superior replacement for Win32API
win32-clipboard (0.4.3, 0.4.1)
A package for interacting with the Windows clipboard
win32-dir (0.3.2, 0.3.1)
Extra constants and methods for the Dir class on Windows.
win32-eventlog (0.4.7, 0.4.3)
Interface for the MS Windows Event Log.
win32-file (0.5.5, 0.5.3, 0.5.2)
Extra or redefined methods for the File class on Windows.
win32-file-stat (1.2.7, 1.2.3)
A File::Stat class tailored to MS Windows
win32-process (0.5.6, 0.5.1)
Adds create, fork, wait, wait2, waitpid, and a special kill method
win32-sapi (0.1.4, 0.1.3)
An interface to the MS SAPI (Sound API) library.
win32-sound (0.4.1, 0.4.0)
A library for playing with sound on MS Windows.
windows-api (0.2.1)
An easier way to create methods using Win32API
windows-pr (0.8.0, 0.6.2)
Windows functions and constants bundled via Win32::API
The problem with ruby-pg is during installation, it complains about pg_config. It can't find it in my PATH but it's there. Check output below please
C:\download\ruby-pg>pg_config
BINDIR = D:/tools/POSTGR~1.1/bin
DOCDIR = D:/tools/POSTGR~1.1/doc
INCLUDEDIR = D:/tools/POSTGR~1.1/include
PKGINCLUDEDIR = D:/tools/POSTGR~1.1/include
INCLUDEDIR-SERVER = D:/tools/POSTGR~1.1/include/server
LIBDIR = D:/tools/POSTGR~1.1/lib
PKGLIBDIR = D:/tools/POSTGR~1.1/lib
LOCALEDIR = D:/tools/PostgreSQL8.3.0.1/share/locale
MANDIR = D:/tools/PostgreSQL8.3.0.1/man
SHAREDIR = D:/tools/POSTGR~1.1/share
SYSCONFDIR = D:/tools/PostgreSQL8.3.0.1/etc
PGXS = D:/tools/PostgreSQL8.3.0.1/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = --enable-thread-safety --enable-nls --with-ldap --with-libxml --with-libxslt --with-krb5 --with-tcl --with-perl --with
-python
VERSION = PostgreSQL 8.3.0
C:\download\ruby-pg>ruby ext\extconf.rb config
The system cannot find the path specified.
ERROR: can't find pg_config.
HINT: Make sure pg_config is in your PATH
*** ext/extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--srcdir=ext
--curdir
--ruby=D:/tools/ruby/bin/ruby
May be am doing something wrong ?
Want me to uninstall DBI-0.2.0 and install DBI 0.1.1 and do tests with ruby-postgres ?
Thanks Erik
|
By: Erik Hollensbe
RE: DBI :: Postgresql not working on windows [ reply ] 2008-04-01 10:34
|
Do you have the 'ruby-pg' library installed?
It's here:
http://rubyforge.org/projects/ruby-pg/
If so, we have a real problem (I haven't been able to test on windows), otherwise, that error message could really use some work. From it, I believe that it's a load path issue.
The load path code needs to be gutted and replaced with something infinitely simpler. This is a target for 0.4.0.
Also curious, if you have the 'ruby-pg' driver installed and it's not working, install the 'ruby-postgres' driver and tell me if DBI 0.1.1 works for you.
|
By: Salvatore Quercia
DBI :: Postgresql not working on windows [ reply ] 2008-04-01 08:19
|
Hi all,
I'm a bit lost in my problem with dbi gem not working when connecting to Postresql 8.3.1 DB.
I've installed dbi successfully, downloaded from this URI http://rubyforge.org/frs/?group_id=234&release_id=20222
I've used this guideline except my config is:
ruby setup.rb config --with=dbi,dbd_mysql,dbd_pg,dbd_oracle,dbd_db2,dbd_odbc,dbd_sqlite,dbd_sqlite3
This is the install output:
C:\download\dbi-0.2.0>ruby setup.rb install
entering install phase...
mkdir -p D:/tools/ruby/bin
install sqlsh.rb D:/tools/ruby/bin
setup.rb: skip bin/proxyserver(dbd_proxy) by user option
mkdir -p D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/Mysql
install Mysql.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb
mkdir -p D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/SQLite
install SQLite.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/SQLite/SQLite.rb
mkdir -p D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/Pg
install Pg.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/Pg/Pg.rb
mkdir -p D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/DB2
install DB2.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/DB2/DB2.rb
mkdir -p D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/Oracle
install Oracle.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/Oracle/Oracle.rb
mkdir -p D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/SQLite3
install SQLite3.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/SQLite3/SQLite3.rb
mkdir -p D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/ODBC
install ODBC.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/DBD/ODBC/ODBC.rb
mkdir -p D:/tools/ruby/lib/ruby/site_ruby/1.8/dbi
install columninfo.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/dbi
install row.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/dbi
install sql.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/dbi
install trace.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/dbi
install utils.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/dbi
install version.rb D:/tools/ruby/lib/ruby/site_ruby/1.8/dbi
install dbi.rb D:/tools/ruby/lib/ruby/site_ruby/1.8
setup.rb: skip ext/dbd_sybase(dbd_sybase) by user option
install done.
My postgresql db is running as a service on windows 2000. A bit old as OS, you are right, but it's the OS used in the company I'm working for.
this is the output of directory DBD wher eyou can see all drivers installed:
D:\tools\ruby\lib\ruby\site_ruby\1.8\DBD>dir
Directory of D:\tools\ruby\lib\ruby\site_ruby\1.8\DBD
28.03.2008 16:12 <DIR> .
28.03.2008 16:12 <DIR> ..
28.03.2008 16:12 <DIR> DB2
28.03.2008 16:12 <DIR> Mysql
28.03.2008 16:12 <DIR> ODBC
28.03.2008 16:12 <DIR> Oracle
28.03.2008 16:12 <DIR> Pg
23.01.2008 12:59 <DIR> Proxy
28.03.2008 16:12 <DIR> SQLite
28.03.2008 16:12 <DIR> SQLite3
0 File(s) 0 bytes
10 Dir(s) 7.735.607.296 bytes free
Please note the Pg.rb file is existing
D:\tools\ruby\lib\ruby\site_ruby\1.8\DBD\Pg>dir
Directory of D:\tools\ruby\lib\ruby\site_ruby\1.8\DBD\Pg
28.03.2008 16:12 <DIR> .
28.03.2008 16:12 <DIR> ..
28.03.2008 16:12 27.906 Pg.rb
1 File(s) 27.906 bytes
2 Dir(s) 7.735.607.296 bytes free
So this is my script:
#!/usr/bin/ruby
#puts "$: is #{$:}"
require 'dbi'
def connect_to_postgres()
puts "\nConnecting to Postgres..."
return DBI.connect('DBI:Pg:postgres:localhost', 'postgres', '*Foo*','')
end
def exercise_database(dbh)
query = dbh.prepare("select tablename, tableowner from pg_tables")
query.execute()
while row = query.fetch() do
puts row
end
end
def main()
dbh = connect_to_postgres()
exercise_database(dbh)
dbh.disconnect
end
main()
And the output:
>ruby dbi_psql_test.rb
Connecting to Postgres...
D:/tools/ruby/lib/ruby/site_ruby/1.8/dbi.rb:368:in `load_driver': Could not load driver (no such file to load -- D:/tools/ruby/lib/ruby/site_ruby/1.8/dbd/Pg) (DBI::InterfaceError)
from D:/tools/ruby/lib/ruby/site_ruby/1.8/dbi.rb:233:in `_get_full_driver'
from D:/tools/ruby/lib/ruby/site_ruby/1.8/dbi.rb:219:in `connect'
from dbi_psql_test.rb:9:in `connect_to_postgres'
from dbi_psql_test.rb:22:in `main'
from dbi_psql_test.rb:27
>Exit code: 1
What is wrong please ?
What URI or good book can give me more informations about database usage with ruby please ?
Thanks.
Sly
|
|
 |