Run update (oracle) completing statement from Dataframe


I have the following Dataframe (df)

id   b   c

1    a   x1

2    a   xx1

3    b   x1

4    d   xxxx1

What I want to do from my script of python is a update to a database Oracle and that it is completed and executed reading from my df, that is something like this

dupdate=pd.read_sql("update tabla set campo=df['c'] where id = df['id'] and b=df['b']",engine)

Thanks Greetings

asked by Ro. 26.11.2018 в 16:01

1 answer


you must make a loop since it is an arrangement:

for i in range(0,len(df['c'])):
  dupdate=pd.read_sql("update tabla set campo={0} where id = {1} and b={2}".format(df['c'][i],df['id'][i],df['b'][i]),engine)
  # lo que sigue en tu codigo
answered by 26.11.2018 в 17:16