code: def gen_columns(obj) -> Generator[Tuple[str, Column], None, None]:
      
      mapper = obj.__mapper__  # type: Mapper
      assert mapper, "gen_columns called on {!r} which is not an " \
                     "SQLAlchemy ORM object".format(obj)
      colmap = mapper.columns  # type: OrderedProperties
      if not colmap:
          return
      for attrname, column in colmap.items():
          # NB: column.name is the SQL column name, not the attribute name
          yield attrname, column
docs: Asks a SQLAlchemy ORM object: "what are your SQLAlchemy columns?"
  
      Yields tuples of ``(attr_name, Column)`` from an SQLAlchemy ORM object
      instance. Also works with the corresponding SQLAlchemy ORM class. Examples:
  
      .. code-block:: python
  
          from sqlalchemy.ext.declarative import declarative_base
          from sqlalchemy.sql.schema import Column
          from sqlalchemy.sql.sqltypes import Integer
  
          Base = declarative_base()
  
          class MyClass(Base):
              __tablename__ = "mytable"
              pk = Column("pk", Integer, primary_key=True, autoincrement=True)
              a = Column("a", Integer)
  
          x = MyClass()
  
          list(gen_columns(x))
          list(gen_columns(MyClass))