Skip to content

Instantly share code, notes, and snippets.

@KennethanCeyer
Created December 13, 2016 13:42
Show Gist options
  • Save KennethanCeyer/e6b29ab77204744966b0f4bb6a4f63f6 to your computer and use it in GitHub Desktop.
Save KennethanCeyer/e6b29ab77204744966b0f4bb6a4f63f6 to your computer and use it in GitHub Desktop.
Inconvenience things of python.
# this is only for examination.
query = "SELECT * from information_schema.tables"
cursor.execute(query)
# why we must use those logic more.
columns = cursor.description
result = []
for value in cursor.fetchall():
tmp = {}
for (index, column) in enumerate(value):
tmp[columns[index][0]] = column
result.append(tmp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment