D
D
Dmitry Sviridov2020-03-03 16:01:07
MySQL
Dmitry Sviridov, 2020-03-03 16:01:07

How to make go and Sphinx friends?

I'm trying to connect to Sphinx in a Go program via the MySQL driver and I'm getting the commands out of sync error. Did you run multiple statements at once? for any request. Here is an example program. In this case, the Ping() method returns an error. I tried the ?multiStatements=true parameter in the DSN string (although I don't think it has anything to do with it) - it didn't help. What am I doing wrong and how to solve the problem?

package main

import (
  "database/sql"
  "fmt"
  _ "github.com/go-sql-driver/mysql"
)


func main() {
  db, err := sql.Open("mysql", "tcp(127.0.0.1:9312)/")
  if err != nil {
    fmt.Println(err)
  }
  defer db.Close()
  fmt.Println(db.Ping())
}

Ps Everything is fine with Sphinx, the php project successfully interacts with it.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladislav, 2020-03-03
@ghostiam

Remove Ping, Sphinx is a stripped down set of mysql commands.
Also, do not use prepared statements, they are not supported by them either. But do not be afraid, sql injection in Sphinx does not threaten.

P
Puma Thailand, 2020-03-04
@opium

Why the hell are you doing prepare and some kind of ping? You read what the sphinx can do

D
Dmitry Sviridov, 2021-07-09
@dimuska139

Might be useful to someone. Now there is no point in using Sphinx, because. there are Manticore - they are compatible. And there is an official sdk client to work with Manticore for Go .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question