i need to perform update query in spark job. i am trying below code. but facing issues.
import cx_Oracle
def query(sql):
connection = cx_Oracle.connect("username/password@s<url>/db")
cursor = connection.cursor()
cursor.execute(sql)
result = cursor.fetchall()
return result
v = [10]
rdd = sc.parallelize(v).coalesce(1)
rdd.foreachPartition(lambda x : [query("UPDATE db.tableSET MAPPERS ="+str(i)+" WHERE TABLE_NAME = 'table_name'") for i in x])
when i execute the above process i am getting below error.
cx_Oracle.InterfaceError: not a query
i tried to update manually using below code.
result = query("<update query>")
when i do this, job is executing continuously