On Dec 10, 7:00 pm, dave <[email protected]> wrote: > I've used the snippet of code below on my devlopement box fine (using > linux) and on another Linux box. > > Now porting to windows and i'm getting a undefined constant DBI error. > I've realised i didn't have DBI gem installed then thought it would > "just fix the error" it hasn't. > > I'm not requiring dbi in code only logger & sequel gems. > I've tried Sequel::DatabaseError in place to no joy. > > using ruby 1.8.7.p302 > > the current code is this... > > @db = Sequel::connect(:adapter => 'mysql', :host => > 'localhost', :database => 'adb', :user => 'user', :password => > 'password') > > rescue DBI::DatabaseError => e > �[email protected]("An error occurred\nError code: #{e.err}\nError > message: #{e.errstr}")
It's pointless to rescue DBI::DatabaseError. You aren't using DBI, and even if you were, sequel would be raising a connection error as a Sequel::DatabaseConnectionError instance. That's not the cause of your problem, though. > OR > > rescue Sequel::DatabaseError => e > �[email protected]("An error occurred\nError code: #{e.err}\nError > message: #{e.errstr}") > > ensure > �[email protected]('DB closed!') > �[email protected] if @db <<<<<<< Also getting an error > sometimes referring to @db not being initialised! > > all the above works as is and I'm happy with it under Linux OS. > > error messages below.... > > For DBI use, > > sequel1.rb:24:in `initialize': uninitialized constant Dopen::DBI > (NameError) > from sequel1.rb:162:in `new' > from sequel1.rb:162 > > Using the Sequel::DatabaseError I get and suspect this is because i > don't have mysql server on this PC.but that's only because of the > mysql (Sequel::AdapterNotFound) error but why? You are using the mysql adapter, so you need the mysql gem installed. > I'm connecting to a remote mysql server and have internet connection > active. > > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original > _require': LoadError: no such file to load -- mysql > (Sequel::AdapterNotFound) > from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ This should make it obvious what the problem is. Install the mysql gem and the problem should go away. Jeremy -- 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.
