On Mar 11, 3:49 pm, mscd000 <[email protected]> wrote:
> Hi everyone,
>
> I want to catch an exception on sequel->connect error. When I run the
> following code with the mysql DB stopped it keeps executing:
>
> require 'sequel'
> DB = Sequel.connect('mysql://user:[email protected]/database')
> items = DB[:items]
>
> I don't get ANY exception thrown...but once I ask the DB for data
> with:
>
> items.all
>
> Here I get the exception: Sequel::DatabaseConnectionError:
> Mysql::Error: Can't connect to MySQL server on '127.0.0.1' (61)
>
> How can I catch the exception when connecting ?

You currently have to call the following after connecting:

  DB.test_connection

Otherwise, Sequel doesn't connect to the database until the first time
it needs to run a query.

However, a :test option to Sequel.connect makes sense to me.  I've
added it to my todo list.

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.

Reply via email to