Can't get ActiveRecord to work with Ruby and Postgres

Hi all,

I'm experimenting with ActiveRecord with Ruby -- no Rails. I installed both
the Mysql and Postgres (the C one, not the fully Ruby one) database dependent
drivers. I can use them to manipulate their databases, respectively. I
installed DBI, and can get it to manipulate both the MySQL and the Postgres
database, and except for a couple things, do it in a database independent
way.

I installed ActiveRecord (via an old Rails install), and can get it to
interact with the MySQL database. However, when I try to get it to interact
with the Postgres database, I get the following error:

[slitt@mydesk ~]$ ./test2.rb
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:79:in
`establish_connection': database configuration specifies nonexistent pg
adapter (ActiveRecord::AdapterNotFound)
        from ./test2.rb:5
[slitt@mydesk ~]$

I'll leave my code at the bottom of this email. When I comment out
the :adapter =>"pg" statement, it works perfectly with MySQL. But when I
instead comment out the :adapter =>"mysql" statement, it errors out as
explained earlier.

What steps should I take to identify the cause of this problem?

Thanks

SteveT

#!/usr/bin/ruby
require 'rubygems'
require_gem 'activerecord'

ActiveRecord::Base.establish_connection(
# :adapter => "mysql",
  :adapter => "pg", # adapter not found error, investigate
  :database => "test",
  :user => "myid"
)

class Rock < ActiveRecord::Base
end

newrow = Rock.new
newrow.rockname = "Bassalt"
newrow.save

puts Rock.find(:first).rockname
puts "Now let's see them all!"
whatever = Rock.find(:all)
whatever.each do |row|
  print row.id, " ", row.rockname, "\n"
end

Rock.delete_all("rockname = 'Bassalt'")

Shouldn't the above be

:adapter=>"postgresql"

Jake

···

On 8/25/06, Steve Litt <slitt@troubleshooters.com> wrote:

ActiveRecord::Base.establish_connection(
# :adapter => "mysql",
  :adapter => "pg", # adapter not found error, investigate
  :database => "test",
  :user => "myid"
)

Yep! That fixed it. I still have some sort of permission problem, but I can
fix that.

Thanks Jake.

Steve

Steve Litt
Author:
   * Universal Troubleshooting Process courseware
   * Troubleshooting Techniques of the Successful Technologist
   * Manager's Guide to Technical Troubleshooting
   * Twenty Eight Tales of Troubleshooting
   * Rapid Learning: Secret Weapon of the Successful Technologist

···

On Friday 25 August 2006 02:45 pm, Jake Cutter wrote:

On 8/25/06, Steve Litt <slitt@troubleshooters.com> wrote:
> ActiveRecord::Base.establish_connection(
> # :adapter => "mysql",
>
> :adapter => "pg", # adapter not found error, investigate
> :database => "test",
> :user => "myid"
>
> )

Shouldn't the above be

:adapter=>"postgresql"