0

I am new to Python and was trying to do coding to understand it more. I have an expense sheet which is not a structured one and using python I managed to extract,clean and load required data into an excel sheet.

Data loaded in Excel

I want to load the same data in oracle db instead of loading in excel file. I initially tried using cx_Oracle and later switched to sqlalchemy thinking that may help

'df.to_sql('AB_EXPENSE',con,if_exists = 'append',index=False)'

But when I execute this I see below error which looks to me like its taking the header also as values to be loaded in table

Error while loading to db

I already have table created in db with cols same as that in dataframe and all I need is to just load/append data alone from Dataframe to respective cols in db.

Data types:

Oracle Table dtype

DF dtype

1 Answers1

0

You have inconsistent datatypes in "year" column between SQL table and pandas df. Type before uploading data:

df.loc[:,'YEARS']=df.loc[:,'YEARS'].astype('int')
Vad1m
  • 389
  • 1
  • 14