title: Inserting into a geospatial field in mysql
body: <p>I have a <code>string</code> object which is representing a polygon in hex and I want to save it into <code>mysql</code> database. I used `` as described <a href="https://dev.mysql.com/doc/refman/8.0/en/populating-spatial-columns.html" rel="nofollow noreferrer">here</a>. Here's the method I used to generate the polygon:</p>
  
  <pre><code>func GetPolygon(coordinates [][]geom.Coord) (string, error) {
      unitSquare := geom.NewPolygon(geom.XY).MustSetCoords(coordinates)
  
      polygon, err := wkb.Marshal(unitSquare, wkb.NDR)
      if err != nil {
          fmt.Printf("wkb marshal error: %s\n", err.Error())
          return "", err
      }
  
      polygonHex := hex.Dump(polygon)
      return polygonHex, nil
  }
  </code></pre>
  
  <p>And this is how I generate my query:</p>
  
  <pre><code>insertQuery := fmt.Sprintf(`INSERT INTO my_table (polygon) VALUE (ST_GeomFromWKB(X'%v'))`, poly)
  </code></pre>
  
  <p>But when I execute the query, I get: </p>
  
  <pre><code>Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'X'00000000  01 03 00 00 00 01 00 00  00 92 00 00 00 ff ff ff  |................|' at line 1
  </code></pre>