code: def get_rows_fieldnames_from_query(
          session: Union[Session, Engine, Connection],
          query: Query) -> Tuple[Sequence[Sequence[Any]], Sequence[str]]:
      
      # https://stackoverflow.com/questions/6455560/how-to-get-column-names-from-sqlalchemy-result-declarative-syntax  # noqa
      # No! Returns e.g. "User" for session.Query(User)...
      # fieldnames = [cd['name'] for cd in query.column_descriptions]
      result = session.execute(query)  # type: ResultProxy
      fieldnames = result.keys()
      # ... yes! Comes out as "_table_field", which is how SQLAlchemy SELECTs
      # things.
      rows = result.fetchall()
      return rows, fieldnames
docs: Returns results and column names from a query.
  
      Args:
          session: SQLAlchemy :class:`Session`, :class:`Engine`, or
              :class:`Connection` object
          query: SQLAlchemy :class:`Query`
  
      Returns:
          ``(rows, fieldnames)`` where ``rows`` is the usual set of results and
          ``fieldnames`` are the name of the result columns/fields.