Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pyodbc cursor create list of dictionaries

conn = pyodbc.connect( connectionString )
cursor = conn.cursor()
cursorQuery = "SELECT * FROM .."
cursor.execute( cursorQuery )
records = cursor.fetchall()
insertObject = []
columnNames = [column[0] for column in cursor.description]

for record in records:
    insertObject.append( dict( zip( columnNames , record ) ) )
 
PREVIOUS NEXT
Tagged: #pyodbc #cursor #create #list #dictionaries
ADD COMMENT
Topic
Name
7+4 =