Skip to content

Instantly share code, notes, and snippets.

@ksindi
Created October 23, 2015 20:44
Show Gist options
  • Save ksindi/c25f6a966a181a88afe7 to your computer and use it in GitHub Desktop.
Save ksindi/c25f6a966a181a88afe7 to your computer and use it in GitHub Desktop.
Return rows as namedtuples
names = " ".join(d[0] for d in cursor.description)
cls = collections.namedtuple('Results', names)
rows = map(cls._make, cursor.fetchall())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment