Golang database/sql/driver.Execer type example
package database/sql/driver
Execer is an optional interface that may be implemented by a Conn.
If a Conn does not implement Execer, the sql package's DB.Exec will first prepare a query, execute the statement, and then close the statement.
Exec may return ErrSkip.
Golang database/sql/driver.Execer type usage example
// creates a new wrap and registers it with the name "debug"
wrap := dbwrap.New("debug", pqdrv(0))
...
// is used instead of conn.Exec
wrap.HandleExec = func(exec driver.Execer, query string, args []driver.Value) (driver.Result, error) {
fmt.Println("exec: ", query)
// do the real Exec and return the result
return exec.Exec(query, args)
}
References :
https://github.com/metakeule/dbwrap/blob/master/example/simple.go
Advertisement
Something interesting
Tutorials
+18.8k Golang : Get host name or domain name from IP address
+4.6k Golang : A program that contain another program and executes it during run-time
+13.1k Golang : Verify token from Google Authenticator App
+8.7k Golang : Go as a script or running go with shebang/hashbang style
+12k Golang : How to check if a string starts or ends with certain characters or words?
+7.1k Golang : Check to see if *File is a file or directory
+12.7k Golang : Calculate elapsed years or months since a date
+7.4k Golang : Trim everything onward after a word
+8.1k Useful methods to access blocked websites
+4.6k Golang : PGX CopyFrom to insert rows into Postgres database
+34.9k Golang : Integer is between a range