title: How can i display pdf in django which is stored in mysql database as blob?
body: <p>In my web application, user can upload a pdf file and the same is stored in the mysql database itself. The file is stored in database using following codes.
  Note : file kept in database because of security related issues. </p>
  
  <pre><code>    data=request.FILES['file'].read()
      fcursor = db.cursor()
      fcursor.execute("INSERT INTO REPORTS(DOC,id) VALUES(%s,%s)",(data,id))
      db.commit()
      fcursor.close()
      db.close()
  </code></pre>
  
  <p>User has provision to view this pdf. Now i transfer the pdf to template with the help of temporary files. </p>
  
  <pre><code>c = db.cursor()
  c.execute("SELECT DOC FROM REPORTS WHERE id=%s",(id,))
  file = c.fetchone()[0]
  c.close()
  
  f=tempfile.NamedTemporaryFile(dir='/tmp/',suffix='.pdf')
  f.write(filename)
  f.seek(0)
  response = HttpResponse(f, content_type='application/pdf')
  response['Content-Disposition'] = 'inline; filename="report.pdf"'
  return response
  </code></pre>
  
  <p>But actually, i wanna display pdf directly from the database, without using the temporary file.</p>