i have a pl/sql contents in a .sql file with some insert/update oracle sql commands in it.
Is it possible in python to call that .sql file and execute contents in it.
testdata.sql file has contents in below format:
Is it possible in python to call that .sql file and execute contents in it.
testdata.sql file has contents in below format:
SET DEFINE OFF; DECLARE BEGIN update tbl1 set UPD_D = to_date(sysdate-1,'DD-MON-RRRR HH24:MI:SS'); update tbl2 set UPD_DT = to_date(sysdate-1,'DD-MON-RRRR HH24:MI:SS'); COMMIT; END;My python code im using it is as below:
import cx_Oracle
import json
import execsql.py
with open('InputData.json') as f:
global data
data = json.load(f)
f = open("testdata.sql")
full_sql = f.read()
sql_commands = full_sql.split(';')
conn = cx_Oracle.connect(data["usrid"],data["pwd"],data["conn"])
curs = conn.cursor()
print("Connection Sucess")
curs.execute(full_sql)Error:Error on running python code is as below:
File "tstsqlfile.py", line 24, in <module>
curs.execute(full_sql)
DatabaseError: ORA-00933: SQL command not properly ended
