Currently, I have several databases with the same tables and columns (but different data inside). So I have to use bindings to access all of them, but this is apparently not as simple as doing it:
class WhateverTable(db.Model): __tablename__ = 'whatevertable' whatever = db.Column(db.String(255)) def __init__(self, bind=None): self.__bind_key__ = bind
and then later:
WhateverTable(bind='bind_key_here').query.filter_by(whatever='whatever').first()
Is there a way I can do this easily? I tried to inherit from a table class and then defined the binding there, and although this works, it really does not scale.
EDIT: This: Flask inherited table classes in several identical databases using __bind_key__ does what I want, but I donβt want to have different classes, because if I ever add a new database, I will have to create a new set of classes and relationship.
source share