sqlalchemy - get attribute names of class python/ get column names of query -
i want have column names of sqlalchemy query not find how can this.
i tried few ways
first way have tried make new class, because names had different of column names
class dosierweergave(): def __init__(self, code_arg, year_registr, period_registr, staynum, status): self.code_arg = str(code_arg) self.year_registr = str(year_registr) self.period_registr = str(period_registr) self.staynum = str(staynum) self.status = str(status)
and maked object of this
a = dosierweergave(187,2010,4,"0000010000", "inbehandeling")
i right names not in right order. know how can columnnames (class attributes) in right order.
another way use function: columns.keys()
headerdosiers = dosiers2.__table__.columns.keys()
but got column headers , not find how can filter them has idea how can fix problems or has got better way it
what want column names; if want print them, create str function:
def __str__(self): str = 'code arg', self._code_arg str += 'year_registr', self.year_registr ... return str
i not suggest using reflection.
Comments
Post a Comment