How to get column names from SQLAlchemy result (declarative syntax)

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import (Column, Index, Date, DateTime, Numeric, BigInteger, String, ForeignKey, Boolean)

Base = declarative_base()

class Project(Base):
    """sqlalchemy ORM for my table."""
    __tablename__ = "table1"
    id = Column("id", BigIntegerID, primary_key=True, autoincrement=True)
    date = Column("date", Date, nullable=False)
    value = Column("value", Numeric(20, 8))
    ...
    ...

Then this will return the columns names ['id', 'date', 'value', ...]:

Project.__table__.columns.keys()

Or this

Project.metadata.tables['table1'].columns.keys()

You can do something similar to Foo Stack's answer without resorting to private fields by doing:

conn.execute(query).keys()