title: How do I read cx_Oracle.LOB data in Python?
body: <p>I have this code:</p>
  
  <pre><code>    dsn = cx_Oracle.makedsn(hostname, port, sid)
      orcl = cx_Oracle.connect(username + '/' + password + '@' + dsn)
      curs = orcl.cursor()
      sql = "select TEMPLATE from my_table where id ='6'"
      curs.execute(sql)
      rows = curs.fetchall()
      print rows
      template = rows[0][0]
      orcl.close()
      print template.read()
  </code></pre>
  
  <p>When I do <code>print rows</code>, I get this:</p>
  
  <pre><code>[(&lt;cx_Oracle.LOB object at 0x0000000001D49990&gt;,)]
  </code></pre>
  
  <p>However, when I do <code>print template.read()</code>, I get this error:</p>
  
  <blockquote>
    <p>cx_Oracle.DatabaseError: Invalid handle!</p>
  </blockquote>
  
  <p>Do how do I get and read this data? Thanks.</p>