I have a dataframe that I want to upload to a SQL Server database.
I have been looking at the pandas to_sql method but I can't seem to get it to work.
My dataframe is say 500 rows with 3 columns
column name data type
dateLg datetime
temperature float64
city object
And so my SQL table is called tblCityTemperature
column name data type
DateLeg datetime
Temp float
CC nvarchar(20)
Is there a way of mapping the columns in a dataframe to my sql table?
I tried the following where tblColNames is the three names in my sql table.
df.to_sql("tblPrices", cnxn, index_label=tblColNames)
I get the error message below which doesn't really make sense to me
ValueError: Length of 'index_label' should match number of levels, which is 1