S
Steve Litt
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.findfirst).rockname
puts "Now let's see them all!"
whatever = Rock.findall)
whatever.each do |row|
print row.id, " ", row.rockname, "\n"
end
Rock.delete_all("rockname = 'Bassalt'")
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.findfirst).rockname
puts "Now let's see them all!"
whatever = Rock.findall)
whatever.each do |row|
print row.id, " ", row.rockname, "\n"
end
Rock.delete_all("rockname = 'Bassalt'")