D
Daniel
Hi,
I am Daniel, started to work on a application in Ruby. Im
rebuliding a application to ruby from MSAccess. since Im new to Ruby, I
have worked on a code to connect to PostgreSQL. But Im getting a error
message. Can someone help me out. I tired with someother options for
the database provider. I have pasted the code and the error message.
Code:
require 'dbi'
begin
# connect to the MySQL server
# dbh =
DBI::connect("PostgreSQL;localhost;inventory_dev","postgres","B4ckN3w!!")
#dbh=DBI.connect("driver=pg host=localhost port=5432
dbname=inventory_dev user=PostgreSQL password=vacn2002!")
#dbh = DBI.connect('localhostostgreSQL:inventory_dev','PostgreSQL',
'vacn2002')
#dbh=DBI.connect(driver="Pg",
database="host=localhost,dbname=inventory_dev")
#obj.login(user="PostgreSQL", pass="B4ckN3w!!")
dbh = DBI.connect("PostgreSQL","inventory_dev", "postgres",
"B4ckN3w!!")
#dbh = DBI.connect("DBIg:inventory_dev")
#dbh = DBI.connect("Driver={SQL
Server};Server=Intel266;Database=Inventory_DEV;Uid=sa;Pwd=vacn2002;")
# get server version string and display it
row = dbh.select_one("select * from UserList")
puts row
#puts "Server version: " + row[0]
rescue DBI:atabaseError => e
puts "An error occurred"
puts "Error code: #{e.err}"
puts "Error message: #{e.errstr}"
ensure
# disconnect from server
dbh.disconnect if dbh
end
Error:
Source Name (DBI::InterfaceError)
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:226:in `_get_full_driver'
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect'
from DbConn.rb:13
I am Daniel, started to work on a application in Ruby. Im
rebuliding a application to ruby from MSAccess. since Im new to Ruby, I
have worked on a code to connect to PostgreSQL. But Im getting a error
message. Can someone help me out. I tired with someother options for
the database provider. I have pasted the code and the error message.
Code:
require 'dbi'
begin
# connect to the MySQL server
# dbh =
DBI::connect("PostgreSQL;localhost;inventory_dev","postgres","B4ckN3w!!")
#dbh=DBI.connect("driver=pg host=localhost port=5432
dbname=inventory_dev user=PostgreSQL password=vacn2002!")
#dbh = DBI.connect('localhostostgreSQL:inventory_dev','PostgreSQL',
'vacn2002')
#dbh=DBI.connect(driver="Pg",
database="host=localhost,dbname=inventory_dev")
#obj.login(user="PostgreSQL", pass="B4ckN3w!!")
dbh = DBI.connect("PostgreSQL","inventory_dev", "postgres",
"B4ckN3w!!")
#dbh = DBI.connect("DBIg:inventory_dev")
#dbh = DBI.connect("Driver={SQL
Server};Server=Intel266;Database=Inventory_DEV;Uid=sa;Pwd=vacn2002;")
# get server version string and display it
row = dbh.select_one("select * from UserList")
puts row
#puts "Server version: " + row[0]
rescue DBI:atabaseError => e
puts "An error occurred"
puts "Error code: #{e.err}"
puts "Error message: #{e.errstr}"
ensure
# disconnect from server
dbh.disconnect if dbh
end
Error:
c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:359:in `parse_url': Invalid Dataruby DbConn.rb
Source Name (DBI::InterfaceError)
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:226:in `_get_full_driver'
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect'
from DbConn.rb:13