shad-go/lectures/07-sql/sqlx/named.go
2020-04-09 14:15:54 +03:00

21 lines
303 B
Go

package sqlx
import (
"context"
"log"
"github.com/jmoiron/sqlx"
)
func Insert(ctx context.Context, db *sqlx.DB) {
_, err := db.NamedExecContext(
ctx,
"INSERT INTO users(name) VALUES(:name)",
map[string]interface{}{
"name": "Jukka Sarasti",
},
)
if err != nil {
log.Fatal(err)
}
}