오브젝트가 sqlalchemy 맵핑 모델의 인스턴스인지 여부를 알고 싶습니다.오브젝트가 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?
더 많은 정보를 제공하십시오! – shahjapan