强制DataMapper与PostgreSQL断开连接 [英] Force DataMapper to disconnect from postgresql
问题描述
我有一个测试,该测试正在postgresql中创建和销毁许多数据库。为了能够删除数据库,我需要告诉DataMapper断开连接。我似乎找不到任何有关此操作的文档。
I have a test that is creating and destroying a number of databases in postgresql. In order to be able to drop a database I need to tell DataMapper to disconnect. I can't seem to find any documentation on how to do that.
DataMapper :: Adapters :: PostgresAdapter上有一个close_connection方法,但是它是受保护的,并且需要我似乎无法获得的连接对象。
There is a close_connection method on DataMapper::Adapters::PostgresAdapter but it is protected and requires a connection object that I can't seem to get.
这甚至可能吗?
推荐答案
DataObjects :: Pooling.pools.each {| pool | pool.dispose}
似乎可以工作,只要您一次只打开一个连接即可。
DataObjects::Pooling.pools.each {|pool| pool.dispose}
seems to work as long as you have only one connection open at a time.
这篇关于强制DataMapper与PostgreSQL断开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!