Yeah, i am creating multipe Database objects, but the case as not the
same as you said, i not use the block, but with a function for
creating the Sequel connect, the code as the following,
def db(name, type)
Sequel.connect("#{type}://db/#{name}/data.db")
end
So, i use the SINATRA as the Controller layer, then,
get '/' do
blog = db('myblog', 'sqlite')
#do something
#do something
pictures = db('pictures', 'mysql')
#do something
#do something
records = db('records', 'postgresql')
#do something
#do something
end
after do
#So, we are here for closing the database connect at once.
#What should i do , or we should do nothing.
end
2011/10/8 Jeremy Evans <[email protected]>:
> On Oct 7, 11:49 pm, coolesting <[email protected]> wrote:
>> For example, how do you end up a ruby script with operating of database.
>
> In general, you don't need to worry about this if your ruby script
> only creates a single Database object, as the connection is
> automatically closed when the ruby process exits. If you are creating
> multiple Database objects, you can use the block form of
> Sequel.connect:
>
> Sequel.connect('connection_string') do |db|
> ...
> end
>
> In this case, the database is automatically disconnected after the
> block closes.
>
> 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.
>
>
--
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.