Skip to content Skip to sidebar Skip to footer

Pyspark: Cx_oracle.interfaceerror: Not A Query

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<

Solution 1:

I resolved my problem. As per Luke inputs. i used fetchall() which is used for querying. i need to use commit(). so changed the code and checked its working fine.

import cx_Oracle
def query(sql):
    connection = cx_Oracle.connect("username/password@s<url>/db")
    cursor = connection.cursor()
    cursor.execute(sql)
    result = connection.commit()
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])

Post a Comment for "Pyspark: Cx_oracle.interfaceerror: Not A Query"