connect SQLAlchemy ORM with the objects from sql core expression?
问题 I have to use SQLalchemy Core expression to fetch objects because ORM can't do "update and returning". (the update in ORM doesn't has returning ) from sqlalchemy import update class User(ORMBase): ... # pure sql expression, the object returned is not ORM object. # the object is a RowProxy. object = update(User) \ .values({'name': 'Wayne'}) \ .where(User.id == subquery.as_scalar()) \ .returning() \ .fetchone() When db_session.add(object) it report UnmappedInstanceError: Class 'sqlalchemy