On Feb 12, 6:29 pm, sohdubom <[email protected]> wrote: > I saw an old sample tutorial with Sqlite and Sequel and although the > sample doesn't really works I got a few doubts: > > 1. The sample use the vendor folder in order to put the init and db > files. I took a simpler path put the following code in my main .rb > file: > > Sequel.connect "sqlite://models/test.db", > :max_connections => 10, > :encoding => 'unicode', > :logger => Logger.new('models/test.log') > > And after that I load the models like: > > require "models/user.rb" > load "models/user.rb" > > It works just fine, but the thing I don't understand is related to the > database connection state. With a code like the one above or any > other, will Sequel manage the connection open/close state? Or with > that code, the connection is always opened?
When you use Sequel.connect, it just establishes the Database object. The actual connection to the database isn't made until the first query is done (you can use test_connection if you want to establish a connection). Once the connection is established, it is left open indefinitely, though you can call disconnect on the database to close all available connections. 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 -~----------~----~----~----~------~----~------~--~---
