bmuller / twistar

Twistar is an object-relational mapper (ORM) for Python that uses the Twisted library to provide asynchronous DB interaction.
http://findingscience.com/twistar
Other
132 stars 38 forks source link

Allow multiple pools #28

Open arski opened 12 years ago

arski commented 12 years ago

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 commented 12 years ago

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?

erikkaplun commented 11 years ago

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

bmuller commented 11 years ago

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.

isnok commented 11 years ago

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.

netanelkl commented 9 years ago

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.

morfair commented 8 years ago

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