I created a simple sql database with a BYTEA field,
create table testhex (testhex bytea);
insert into testhex (testhex) values ('\x123456');
and then I tried to query it from Go.
package main
import (
"database/sql"
_ "github.com/lib/pq"
)
func main(){
var err error
db, err := sql.Open("postgres", "dbname=testhex sslmode=disable")
if err != nil {
panic(err)
}
var result string
err = db.QueryRow("select testhex from testhex where testhex = $1", `\x123456`).Scan(&result)
if err != nil {
panic(err)
}
}
It doesn't find the row. What am I doing wrong?