title: What is the barebones C++ code necessary to put a jpeg into MySQL table?
body: <p>I have created a MySQL table where one of the columns stores a BLOB type. (The Internet told me BLOB is the correct data type for images.)</p>
  
  <p>I am pretty much a beginner with both C++ and MySQL. What I would like to do is to write a small program with a main() that puts a jpeg into that table. For the sake of this exercise, I do not want to store a reference to a directory that contains an image.</p>
  
  <p>Am I wrong to think that it is as simple as filling out the part in BLOCK 2 below?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;mysql.h&gt;
  
  using namespace std;
  
  int main(int argc, char **argv)
  {
  
      //BLOCK 1: INIT
      MYSQL *connection, mysql;
      MYSQL_RES *result;
      MYSQL_ROW row;
  
      int query_state;
  
      mysql_init(&amp;mysql);
      connection = mysql_real_connect(&amp;mysql, "localhost", "root", "secret", "beginner_db",0,0,0);
  
      //BLOCK 2: SEND QUERY
      /* do something to insert image to table */
  
      //BLOCK 3: DISPLAY QUERY RESULTS
      result = mysql_store_result(connection);
      /* do something with result */
  
      //BLOCK 4: FREE
      mysql_free_result(result);
      mysql_close(connection);
  
      return 0;
  }
  </code></pre>