在sqlite数据库中,我有一个名为 variant 的表和多个具有相同结构的视图。 ( variant1 , variant2 , variant3 ...)
我想拥有一个可以映射到视图并在运行时切换的python类。
class Variant(Base):
__tablename__="variant"
id = Column(Integer,primary_key=True)
name = Column(String)
# show all variant
for i in session.query(Variant):
print(i.name)
# show only variant from view called variant1
# But this is not working. any idea ?
Variant.__tablename__ = "variant1"
for i in session.query(Variant):
print(i.name)