I am new to golang. Can some point me to the right direction with this error.
When attempting to insert json data into a database table, I received error “multiple-value db.Exec() in single-value context.
Here is a simple example to reproduce the problem.
//postgres ddl:
create table signup (id big serial primary key, json jsonb);
//go code:
package main
import (
"database/sql"
_ "
github.com/lib/pq"
"log"
)
func main() {
db, err := sql.Open("postgres", "user=johndoe password='password' dbname=test sslmode=disable")
if err != nil {
log.Fatal(err)
}
//mockup data
data := `{"Email": “
joh...@gmail.com"}`
//insert
err = db.Exec("insert into signup (data) values ($1)", data)
if err != nil {
log.Fatal(err)
}
}