title: Insert image into a database
body: <p>I am trying to insert an image in mysql database with pyqt5. first I used the QFileDialog to select the image from my computer but I cant send it to the database. Please help!!!</p>
  
  <pre><code>def save(self):
      fname = QFileDialog.getOpenFileName(self, "Open File", "C\\", "Image files(*.jpg *.gif *.png)")
      imagePath = fname[0]
      self.mydb = mysql.connector.connect(host = "localhost", user= "manuel", passwd = "fame007dav", database = "cooperative")
      self.mycursor = self.mydb.cursor()
      if self.mycursor:
          print('connected')
  
      with open(imagePath, 'rb') as stream:
          blob = stream.read()
          sql = "INSERT INTO test VALUES(%s)"
          val = (blob)
          self.mycursor.execute(sql, val)
          self.mydb.commit()
          print('Image saved')
  </code></pre>