pyodbc cursor create list of dictionaries

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

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 ) ) )