title: How to insert a data into RDB (MySQL) using Spark?
body: <p>I'm trying to insert a data into <code>MySQL</code> table via <code>Spark SQL</code>.</p>
  
  <p>Here is my table:</p>
  
  <pre><code>CREATE TABLE images (
    id    INT          NOT NULL AUTO_INCREMENT,
    name  VARCHAR(100) NOT NULL,
    data  LONGBLOB     NOT NULL
  );
  </code></pre>
  
  <p>and my <code>Spark</code> code:</p>
  
  <pre><code>case class Image(name: String, data: Array[Byte])
  
  def saveImage(image: Image): Unit = {
    sqlContext.sql(s"""INSERT INTO images (name, data) VALUES ('${image.name}', ${image.data});""".stripMargin)
  }
  </code></pre>
  
  <p>But I get an error:</p>
  
  <pre><code>java.lang.RuntimeException: [1.13] failure: ``table'' expected but identifier images found
  INSERT INTO images (name, data)
              ^
  </code></pre>
  
  <p>What is wrong with my code?</p>