tags:

views:

46

answers:

1

I mean the one which was previously established as

DB = Sequel.sqlite('my_blog.db')

or

DB = Sequel.connect('postgres://user:password@localhost/my_db')

or

DB = Sequel.postgres('my_db', :user => 'user', :password => 'password', :host => 'localhost')

or etcetera.

The Sequel::Database class has no public instance method called "disconnect" or so though it has "connect" one.

Maybe somebody already faced that problem. I would appreciate any idea.

A: 

As Mladen Jablanović points out, you can just do:

DB.disconnect

Which will disconnect all of the available connections in that Sequel::Database instance's connection pool. You can't choose a specific connection to disconnect, and it wouldn't make sense to. The sharded connection pools do support disconnecting all connections for a specific shard, though.

Jeremy Evans
After you told that wouldn't make sense, I started to doubt that I understand connection pools right. The following code assumes that multiple modules can simultaneously use specific connection from DB hash:[[[ DB = {}; DB[:a] Sequel.postgres('a', opts); DB[:b] Sequel.postgres('b', opts); DB[:c] Sequel.postgres('c', opts) ]]].The task is in disconnecting all the DB[:a] connections, actually in releasing the specific database. Is the above approach right? Is that possible? DB[:a].disconnect doesn't work as desired, or I do misunderstand?BTW, many thanks for the toolkit!
MG
Sorry for the ugly message, I'm not yet unaccustomed to Stackoverflow's methods. The example code and clarifications should probably be in a question((
MG
You don't ever get to choose a specific connection to use. Assuming that DB[:a] is your Sequel::Database, DB[:a].disconnect will disconnect all available connections in DB[:a]'s connection pool. If you have more questions, you may want to post on Sequel's Google Group with the code you are using.
Jeremy Evans