[ad_1]
I was trying to fetch the data from a SQL server database into a pandas dataframe. But it was returning entire data into a single column instead of as it was in different columns in the database.When I tried to assign columnname to the dataframe it returned this error
6 columns passed, passed data had 1 columns
It was here when I realized that it is fetching the data into a single column.
So can anyone help me with how can I add fetch the data into different columns or split this data into different columns and assign column names?
Here is the code and the output that I got.
`def read(cursor):
try:
print("Read")
cursor = conn.cursor()
cursor.execute("SELECT * FROM empDetail")
df = pd.DataFrame(cursor)
print(df)
except ValueError as e:
print("Error",e)
`
[ad_2]