On Sun, Nov 19, 2023 at 12:34 AM Sofia Dimant <[email protected]> wrote:

> I have a rails application (with puma) and postgresql databases. As a DB
> driver gem Sequel is used.
>
> I did a test in my program and saw that in this code:
> def test_select
> db = Sequel::Model.db = Sequel.connect(@database_url)
> db['select 1'].first
> db.disconnect
> puts "valid? #{db.test_connection}"
> true
> rescue
> false
> end
>
>   and saw that db connection is valid after disconnect, and the
> Sequel.connect is called  automatically before test_connection
>
> what are the scenarios the Sequel.connect called?
> I saw that if i run a simple query after db.disconnect the Sequel.connect
> is also called
>

Each Sequel::Database has a connection pool.  Database#disconnect
disconnects the current connections in the pool.  The next time you run a
query on the Database, a new connection is created.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSSeVw7EpJR_KCVHqBk4ASK7twxQ7rjYQzRMn%2BCS_pmOkgQ%40mail.gmail.com.

Reply via email to