{"id":34130001,"url":"https://github.com/jbub/sqlcommenter","last_synced_at":"2026-03-09T21:01:38.890Z","repository":{"id":46280626,"uuid":"413833494","full_name":"jbub/sqlcommenter","owner":"jbub","description":"Go implementation of https://google.github.io/sqlcommenter/.","archived":false,"fork":false,"pushed_at":"2022-08-12T07:22:31.000Z","size":25,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-19T17:50:56.041Z","etag":null,"topics":["go","golang","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbub.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-05T13:39:18.000Z","updated_at":"2023-03-06T06:26:31.000Z","dependencies_parsed_at":"2022-08-31T16:32:01.361Z","dependency_job_id":null,"html_url":"https://github.com/jbub/sqlcommenter","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/jbub/sqlcommenter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbub%2Fsqlcommenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbub%2Fsqlcommenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbub%2Fsqlcommenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbub%2Fsqlcommenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbub","download_url":"https://codeload.github.com/jbub/sqlcommenter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbub%2Fsqlcommenter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30312117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","sql"],"created_at":"2025-12-15T00:19:35.647Z","updated_at":"2026-03-09T21:01:38.884Z","avatar_url":"https://github.com/jbub.png","language":"Go","readme":"# sqlcommenter\n[![GoDoc](https://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/jbub/sqlcommenter)\n[![Build Status](https://cloud.drone.io/api/badges/jbub/sqlcommenter/status.svg)](https://cloud.drone.io/jbub/sqlcommenter)\n[![Go Report Card](https://goreportcard.com/badge/github.com/jbub/sqlcommenter)](https://goreportcard.com/report/github.com/jbub/sqlcommenter)\n\nGo implementation of https://google.github.io/sqlcommenter/.\n\n## Usage with pgx stdlib driver\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"database/sql\"\n\n    \"github.com/jackc/pgx/v4/stdlib\"\n    \"github.com/jbub/sqlcommenter\"\n)\n\ntype contextKey int\n\nconst contextKeyUserID contextKey = 0\n\nfunc withUserID(ctx context.Context, key string) context.Context {\n    return context.WithValue(ctx, contextKeyUserID, key)\n}\n\nfunc userIDFromContext(ctx context.Context) string {\n    return ctx.Value(contextKeyUserID).(string)\n}\n\nfunc main() {\n    pgxDrv := stdlib.GetDefaultDriver()\n    drv := sqlcommenter.WrapDriver(pgxDrv,\n        sqlcommenter.WithAttrPairs(\"application\", \"hello-app\"),\n        sqlcommenter.WithAttrFunc(func(ctx context.Context) sqlcommenter.Attrs {\n            return sqlcommenter.AttrPairs(\"user-id\", userIDFromContext(ctx))\n        }),\n    )\n\n    sql.Register(\"pgx-sqlcommenter\", drv)\n\n    db, err := sql.Open(\"pgx-sqlcommenter\", \"postgres://user@host:5432/db\")\n    if err != nil {\n        // handle error\n    }\n    defer db.Close()\n    \n    ctx := context.Background()\n\n    rows, err := db.QueryContext(withUserID(ctx, \"22\"), \"SELECT 1\")\n    if err != nil {\n        // handle error\n    }\n    defer rows.Close()\n    \n    // will produce the following query: SELECT 1 /*application='hello-app',user-id='22'*/\n}\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbub%2Fsqlcommenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbub%2Fsqlcommenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbub%2Fsqlcommenter/lists"}