I am trying to get the mssql table column name and datatype using pyodbc
Here is my code:
def GetSQLTableFields(connDetails):
cursor = conn.ConnectSQL(connDetails)
cursor.execute("SELECT colum1, column2, column3 FROM TEST_TABLE")
for col in cursor.description:
print('name =', col[0], ', datatype =',col[1])
cursor.close()
by using this code i'm not able to get the sql datatype of columns inseted i'm getting this
name = column1, datatype = <class 'str'>
name = column2, datatype = <class 'int'>
output i want
name = column1, datatype = nvarchar
name = column2, datatype = int