Below is the initialization method i use and the results i get below that.
def initialize(*arg)
@path = "/logs"
puts 'in DB connection initialize'
@log = Logger.new("#...@path}db - info.log")
@log.level = Logger::DEBUG
@log.debug('initialing the DB access!')
if arg[0] == 'local'
@db = Sequel.connect(:adapter => 'mysql', :localhost => 'localhost',
:database => 'test', :user => 'dave', :password => 'test')
# local
else
puts 'in remote side'
@db = *Sequel.mysql.connect*(:host => 'remote.co.nz', :database =>
'remote', :user => "my_name", :password => "2010")
# Mysql.new(hostname, username, password, databasename) <<< success
before using teh mysql gem directly.
# @db = Mysql.new('remote.co.nz', "my_name", "2010",'remote')
# remote
end
Thread.new{loop{sleep 60; DB.get(1)}}
rescue Sequel::DatabaseError
@log.debug("An error occurred\nError code: #{Sequel}\nError message:
#{Sequel.to_s}")
ensure
@log.debug("DB closed!")
# @db.disconnect if @db
end
def get_all_acccodes
@log.debug('getting all account codes')
row = @db[:cust_data].filter(:closed => 0, :contract => 0) # 1 = true
account is CLOSED, 0 means it's OPEN
# @db.query('select * from cust_data') <<< successfully got customer
data returned
end
a = Dopen.new 'remote'
ans = a.get_all_acccodes # return all customer data - simple!
ans.each{|e| puts e}
C:\monitoring screen>ruby -rubygems sequel1.rb
in DB connection initialize
in remote side
C:/Ruby187/lib/ruby/gems/1.8/gems/sequel-3.18.0/lib/sequel/adapters/mysql.rb:112
:in `real_connect': Access denied for user 'dave'@'localhost' (using
password: N
O) (Mysql::Error)
from
C:/Ruby187/lib/ruby/gems/1.8/gems/sequel-3.18.0/lib/sequel/adapters
/mysql.rb:112:in `connect'
from sequel1.rb:21:in `initialize'
from sequel1.rb:169:in `new'
from sequel1.rb:169
C:\monitoring screen>
the command I used are...
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.