Skip to content

Instantly share code, notes, and snippets.

@danishabdullah
Last active February 11, 2016 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danishabdullah/6261ba20b40d8b4ecb85 to your computer and use it in GitHub Desktop.
Save danishabdullah/6261ba20b40d8b4ecb85 to your computer and use it in GitHub Desktop.
Get dicts for sqlalchemy core query
def make_dicts_from_result_proxy(proxy):
    res = proxy.fetchall()
    if res:
        keys = res[0].keys()
        res = [dict(zip(keys, i.values())) for i in res]
    return res

make_dicts_from_result_proxy(engine.execute("SELECT * FROM example"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment