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

18 lines
263 B
Go

package named
import (
"context"
"database/sql"
"log"
)
func Insert(ctx context.Context, db *sql.DB) {
_, err := db.ExecContext(
ctx,
"INSERT INTO users(name) VALUES(@name)",
sql.Named("name", "Amos Burton"),
)
if err != nil {
log.Fatal(err)
}
}