pyodbc cursor create list of dictionaries

Solutions on MaxInterview for pyodbc cursor create list of dictionaries by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "pyodbc cursor create list of dictionaries"
Valentine
13 Nov 2019
1conn = pyodbc.connect( connectionString )
2cursor = conn.cursor()
3cursorQuery = "SELECT * FROM .."
4cursor.execute( cursorQuery )
5records = cursor.fetchall()
6insertObject = []
7columnNames = [column[0] for column in cursor.description]
8
9for record in records:
10    insertObject.append( dict( zip( columnNames , record ) ) )