Skip to content

Instantly share code, notes, and snippets.

@dafma
Created July 26, 2017 20:35
Show Gist options
  • Save dafma/82692c67a23ab46a91cc0577aa967b12 to your computer and use it in GitHub Desktop.
Save dafma/82692c67a23ab46a91cc0577aa967b12 to your computer and use it in GitHub Desktop.
sql = "Select Referencia, Agente from Compra where Mov='PEDIDO' and Referencia='898-76' "
cursor = connection.cursor()
cursor.execute(sql)
todo_items = cursor.fetchall()
result = []
keys = ('Referencia','Agente',)
for row in todo_items:
result.append(dict(zip(keys, row)))
#todo_items = ['Mow Lawn', 'Buy Groceries', ]
data = json.dumps(result)
return HttpResponse(data, content_type='application/json')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment