I need to retrieve values from the database for the column names specified. The below code I've tried,
import pyodbc
def get_db_data():
cursor = getConnection.cursor()
cursor.execute("select * from student")
return cursor
cur = get_db_data()
for row in cur.fetchall():
print(row["student_name"])
I'm facing below error
TypeError: row indices must be integers, not str
How to achieve this?