twistar icon indicating copy to clipboard operation
twistar copied to clipboard

Allow multiple pools

Open arski opened this issue 12 years ago • 6 comments

Hi again,

I'm pretty sure this is really not possible in the module: I have an app that works with two different databases (for various reasons), but obviously Twistar only allows one Registry.DBPOOL connection.. Is there anything that could be done to increase this number? Or either way, what would you recommend to do in such a scenario?

Thanks again, Martin

arski avatar Jul 08 '12 19:07 arski

Hmm, I see I can simply create other pools via Registry.DBPOOL2 = ... e.g. But is that OK to do? Will the pool run as properly as the first?

arski avatar Jul 08 '12 19:07 arski

I have the same question. Can I simply assign independent DB pools to model classes?

erikkaplun avatar Nov 16 '12 13:11 erikkaplun

Right now, there's no concept of having multiple pools (let alone, one per class). The only way to get around it would be to manually switch out the value of Registry.DBPOOL to be the pool you want to use for subsequent queries. Not great - I know - but it would require making some pretty big changes to allow for a different pool per class. I'll add this to the list of feature requests.

bmuller avatar Dec 01 '12 23:12 bmuller

But wouldn't changing Registry.DBPOOL at run time affect simultaneously running transactions? I was thinking through another approach: double-importing. Outcome: Will also not work, because other submodules import registry via 'full path'. That will always resolve to the same module instance, even if called from different places.

isnok avatar Sep 12 '13 16:09 isnok

I'm also quite interested in that idea, on don't think it would be extremely difficult. I'll try to work on that over the next week and make a PR for review.

netanelkl avatar Nov 05 '15 21:11 netanelkl

It's very important features! I need in this too.

morfair avatar Sep 27 '16 07:09 morfair