Psycopg2.extras.dictcursor Does Not Give Me Column Names
I am using psycopg2 to access the data from the Postgres database. I am using psycopg2.extras.DictCursor for getting the data in a dict-like form using the following query: try:
Solution 1:
to get all column names you can use the mehtod keys
for row item, for example:
cur.execute("SELECT * FROM card")
result = cur.fetchall()
keys = list(result[0].keys()) if result else []
for row in result:
for key in keys:
print(row[key])
Post a Comment for "Psycopg2.extras.dictcursor Does Not Give Me Column Names"