title: Run SQL Query from Txt File Python
body: <p>Hello i am trying to load a huge query (5000+ lines) from a text file and execute the whole query at the once using the code below. How can i load my query from a txt file and execute it using python pandas</p>
  <p>i opened up my text file using the code below</p>
  <pre><code>query1 = open(&quot;Script.txt&quot;,&quot;r&quot;)
  </code></pre>
  <p>and tried executing the script with the code below.</p>
  <pre><code>df_ora1 = pd.read_sql(query1, con=connection1)
  </code></pre>
  <p>I am getting the following error</p>
  <p>DatabaseError: Execution failed on sql '&lt;_io.TextIOWrapper expecting string or bytes object</p>
  <p>my text file has
  &quot;&quot;&quot; start query</p>
  <p>end query
  &quot;&quot;&quot;</p>