0
nodes = db.query(A.id, B.name,C.name,D.name).outerjoin(B,C,D).filter(A.id==node_id).all()
for item in nodes:
   print(item)

output is <class 'sqlalchemy.engine.row.Row'> (3, 'this is name', None, None)

i want ouput dict like this {'id':3,'B.name':'this is name'...}

What should I do?

Which good brother can help me?

That's what I'm doing now

I believe there will be a good brother and a better way

for item in nodes:
    print(dict(zip(['id','A.name','B.name','C.name'],item)))
IFCZT
  • 89
  • 8
  • From the linked duplicate, [this](https://stackoverflow.com/a/70311205/5320906) is the most modern way - requires 1.4/2.0 style usage. Otherwise [_asdict](https://stackoverflow.com/a/21029850/5320906) is probably the way to go. – snakecharmerb Jan 24 '22 at 10:34

1 Answers1

-1

Doing some quick searches suggests that you could use dict(item) to convert a Row into a dictionary.

I'm not a brother, though. :)

Jasmijn
  • 9,370
  • 2
  • 29
  • 43