github.com/qustavo/sqlhooks
This example shows how to instrument sql queries in order to display the time that they consume package main import ( "context" "database/sql" "fmt" "time" "github.com/gchaincl/sqlhooks" "github.com/mattn/go-sqlite3" ) // Hooks satisfies the sqlhook.Hooks interface type Hooks struct {} // Before hook will print the query with it's args and return the context with the timestamp func (h *Hooks) Before(ctx context.Context, query string, args ...interface{}) (context.Context, error) { fmt.Printf("> %s %q", query, args) return context.WithValue(ctx, "begin", time.Now()), nil } // After hook will get the timestamp registered on the Before hook and print the elapsed time func (h *Hooks) After(ctx context.Context, query string, args ...interface{}) (context.Context, error) { begin := ctx.Value("begin").(time.Time) fmt.Printf(".
proxy.golang.org
v1.3.0
almost 7 years ago
4
github.com/qustavo/sqlhooks/v2 v2.1.0
This example shows how to instrument sql queries in order to display the time that they consume p...3 versions - Latest release: about 5 years ago - 33 dependent packages - 51 dependent repositories - 663 stars on GitHub
Links
| Registry | proxy.golang.org |
| Source | Repository |
| Docs | Documentation |
| JSON API | View JSON |
| CodeMeta | codemeta.json |
Package Details
| PURL |
pkg:golang/github.com/qustavo/sqlhooks
spec |
| License | MIT |
| Namespace | github.com/qustavo |
| First Release | over 9 years ago |
| Last Synced | 16 days ago |
Repository
| Stars | 664 on GitHub |
| Forks | 47 on GitHub |
| Commits | 108 |
| Committers | 11 |
| Avg per Author | 9.818 |
| DDS | 0.259 |