I am new to writing a python code for automation, so my motif is to execute multiple etl testing scripts written in oracle sql and write the result of each query to a csv file, the script has multiple sql queries each query result should be written to a different tab in the csv.. I tried to write a basic structure as below but need help on how I can modify the code below: import os import cx_Oracle import csv
f = open('tabledefinition.sql') #PATH WHERE THE SQL SCRIPTS ARE STORED
full_sql = f.read()
SQL= full_sql.split(';')
filename="S:\Output.csv" # PATH WHERE THE OUTPUT FILE IS STORED
FILE=open(filename,"w");
output=csv.writer(FILE, dialect='excel')
connection = cx_Oracle.connect('userid/password@99.999.9.99:PORT/SID')
#CONNECTION DETAILS FOR DB
cursor = connection.cursor()
for sql_command in SQL:
cursor.execute(SQL)
for row in cursor:
output.writerow(row)
cursor.close()
connection.close()
FILE.close()