title: read oracle sql file using python and fetch results in to CSV file
body: <p>I am beginner to python and want to read a sql file from python and fetch those results in to CSV file. I have tried usin CX_oracle to connect to oracle database. It works when i directly give the sql query in the code. But, I am not sure how to read a sql file from python.</p>
  <p>Here is the code which worked when i gave sql query directly in the code:</p>
  <pre><code>import csv 
  import cx_Oracle
  con = cx_Oracle.connect('XCM/XCM@home.com:1500/HOME')
  cursor = con.cursor()
  csv_file = open(&quot;exp.csv&quot;, &quot;w&quot;)
  writer = csv.writer(csv_file, delimiter='|', lineterminator=&quot;\n&quot;, quoting=csv.QUOTE_NONE)
  r = cursor.execute(&quot;select * from home_parties where CREATION_DATE &gt;= trunc(sysdate)&quot;)
  for row in cursor:
      writer.writerow(row)
  cursor.close()
  con.close()
  csv_file.close()
  </code></pre>
  <p>I tried the below code to fetch from sql file which has the same sql query as mentioned in the above code - sample.sql but it dint work</p>
  <pre><code>import csv
  import cx_Oracle
  con = cx_Oracle.connect('XCM/XCM@home.com:1500/HOME')
  cursor = con.cursor()
  csv_file = open(&quot;exp.csv&quot;, &quot;w&quot;)
  writer = csv.writer(csv_file, delimiter='|', lineterminator=&quot;\n&quot;, quoting=csv.QUOTE_NONE)
  f = open('C:/Users/home1/sample.sql')
  full_sql = f.read()
  r = cursor.execute(full_sql)
  for row in cursor:
      writer.writerow(row)
  cursor.close()
  con.close()
  csv_file.close()
  </code></pre>
  <p>Kindly help me out!!</p>