I'm stuck with a problem about querying multiple databases using Peewee:
- I have 2 existing mysql databases (let's name them A and B) (Structures are similar because it's two Bugzilla databases)
- I generate models (modelsA.py and modelsB.py) using Pwiz
- I write this code:
.
from modelsA import *
from modelsB import *
The problem is: as the classes in modelsB are (sometimes) the same than modelsA, modelsB classes "overwrite" modelsA classes, making impossible to query A.
Besides, I don't understand how to query one of the specific database. For example, with this code:
c = Customers.get(Customers.customernumber == 12)
How do you know on which database this query is gonna be executed?
I had an idea, but it seems dirty to me: I could manually rename classes from modelsA.py and modelsB.py to make them distincts and then write this code:
ca = CustomersA.get(CustomersA.customernumber == 12)
cb = CustomersB.get(CustomersB.customernumber == 12)
Roughly, is Peewee able to deal with these kind of cases? If so, what is the way to do? Snippets would be very appreciated ^^ Thanks.