I have been banging my head trying to get my Sqlite table to update given the code below.. looping through Pandas dataframe cells in specific columns to update specific columns in the sqlite table given a date match.
Everything works up until updating the table but the table won't update. It is always printing Fail. Any help would be greatly appreciated!
cur.execute('ALTER TABLE Car_parts'+Part_str+' ADD COLUMN Close_'+Column_ID+' number')
conn.commit()
cur.execute('ALTER TABLE Car_parts'+Part_str+' ADD COLUMN Volume_'+Column_ID+' number')
conn.commit()
y=0
while y<len(Car_Data.index):
print(y)
Update_date=Car_Data.iloc[y,0]
#Update_date=datetime.strptime(UpdateDate,date_format)
Update_close=str(CAR_Data.iloc[y,1])
Update_volume=str(Car_Data.iloc[y,2])
print(type(Update_date),type(Update_close), type(Update_volume))
try:
cur.execute('UPDATE Car_parts'+Part_str+' SET Close_'+Column_ID+' = ?, Volume_'+Column_ID+' = ? WHERE Date= ?',(Update_Close, Update_Volume, Update_date,))
conn.commit()
print("Success")
except:
print("fail")
pass
y+=1