I'm developing an API in Python FLASK and I need to show the result of a SELECT
I made via SQL ALCHEMY
. But when I use return
it only returns the first ROW
of SELECT
.
The funny thing is that with "print" it displays all results without any problems.
Could anyone help me in this mystery?
def lista_unidades():
uni = session.query(UnidadesMam).all()
for u in uni:
return json.dumps({'Unidade': u.nomeUni, 'Endereco': u.enderecoUni, 'Bairro': u.bairroUni, 'Cep': u.cepUni,
'Cidade': u.cidadeUni, 'Estado': u.estadoUni, 'Pais': u.paisUni})