Я хочу знать, как узнать, заданный объект, является ли он экземпляром модели с отображением sqlalchemy.
Обычно я бы использовал isinstance (obj, DeclarativeBase). Однако в этом сценарии у меня нет доступного используемого класса DeclarativeBase (поскольку он находится в проекте зависимостей).
Я хотел бы знать, какова наилучшая практика в этом случае.
class Person(DeclarativeBase):
__tablename__ = "Persons"
p = Person()
print isinstance(p, DeclarativeBase)
#prints True
#However in my scenario, I do not have the DeclarativeBase available
#since the DeclarativeBase will be constructed in the depending web app
#while my code will act as a library that will be imported into the web app
#what are my alternatives?