The thing is that for my testing (on linux) i was connecting to a local mysql server to get everything running right then I wanted to connect to the production server without having to comment / uncomment lines so put in a simple if test stement to swap between local or the remote.
this works under linux but it's not for windows and I'm wanting to move unfortunately everything to windows. if you look at the commented mysql connection line immediately below the remote Sequel connection line it worked. I coud dump Sequel but I don't as i want it's connection pools and well I've gotten used to it's syntax :). if I use you're suggested connection of *...@db = Sequel.connect(...)* then I get this error... 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:343 : [BUG] Segmentation fault ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. I don't know if this raises a problem with the Sequel gem or the ruby 1.8.7 rubyinstaller. I will now run off and post/logde a bug with the rubyinstaller folks. dave. On 12 December 2010 19:52, Gary Doades <[email protected]> wrote: > On 12/12/2010 5:53 AM, dave lilley wrote: > > 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 <%23...@path%7ddb> - 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'<%27dave...@%27localhost%27>(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> > > > > Why are you using a different connect method for local and remote. The > connect you are using for "local" looks (almost) correct, the "remote" one > is just wrong. All you need to do is use the same construct as for local, > but change the host and perhaps username & password? > > LOCAL > @db = Sequel.connect(:adapter => 'mysql', :host => 'localhost', :database > => 'test', :user => 'dave', :password => 'test') > > REMOTE > @db = Sequel.connect(:adapter => 'mysql', :host => 'remote.co.nz', > :database => 'test', :user => 'dave', :password => 'test') > > > The error you are getting is not from Sequel but from mysql itself, > basically saying the user 'dave' is not allowed to connect to 'localhost'. > This will be from your *local* mysql denying that user access. If you want > to connect to your locally installed mysql with the username 'dave' then you > are going to have to create a user called 'dave'@'localhost' within your > local mysql. > > You might *think* you are connecting remotely, but the error message says > otherwise. You really need to get your connection parameters right. > > http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html > > Cheers, > Gary, > > -- > 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]<sequel-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/sequel-talk?hl=en. > -- 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.
