code: def by_sql(cls, sql, engine_or_session):
          
          ses, auto_close = ensure_session(engine_or_session)
          result = ses.query(cls).from_statement(sql).all()
          if auto_close:
              ses.close()
          return result
docs: Query with sql statement or texture sql.