{"id":20908976,"url":"https://github.com/jaredpetersen/dynamicsqldriver","last_synced_at":"2026-04-20T20:02:38.899Z","repository":{"id":40338573,"uuid":"492079153","full_name":"jaredpetersen/dynamicsqldriver","owner":"jaredpetersen","description":"🍬 Wrap Go SQL drivers for generated credentials support","archived":false,"fork":false,"pushed_at":"2022-05-14T02:46:05.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-19T14:57:36.642Z","etag":null,"topics":[],"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/jaredpetersen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null},"funding":{"github":"jaredpetersen","custom":["https://cash.app/$jaredtpetersen","https://paypal.me/jaredtpetersen"]}},"created_at":"2022-05-14T01:01:22.000Z","updated_at":"2022-05-14T04:18:52.000Z","dependencies_parsed_at":"2022-08-09T17:40:28.633Z","dependency_job_id":null,"html_url":"https://github.com/jaredpetersen/dynamicsqldriver","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredpetersen%2Fdynamicsqldriver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredpetersen%2Fdynamicsqldriver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredpetersen%2Fdynamicsqldriver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredpetersen%2Fdynamicsqldriver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredpetersen","download_url":"https://codeload.github.com/jaredpetersen/dynamicsqldriver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243301129,"owners_count":20269286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-18T14:09:42.415Z","updated_at":"2025-12-24T20:46:46.490Z","avatar_url":"https://github.com/jaredpetersen.png","language":"Go","funding_links":["https://github.com/sponsors/jaredpetersen","https://cash.app/$jaredtpetersen","https://paypal.me/jaredtpetersen"],"categories":[],"sub_categories":[],"readme":"# dynamicsqldriver\n[![CI](https://github.com/jaredpetersen/dynamicsqldriver/actions/workflows/ci.yaml/badge.svg)](https://github.com/jaredpetersen/dynamicsqldriver/actions/workflows/ci.yaml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/jaredpetersen/dynamicsqldriver.svg)](https://pkg.go.dev/github.com/jaredpetersen/dynamicsqldriver)\n\ndynamicsqldriver is a SQL driver implementation for Go that wraps your favorite SQL driver and adds the ability to\ngenerate credentials any time the SQL package opens up a new connection. This is particularly useful with secrets\nmanagement systems like HashiCorp Vault that generate and manage database users on your behalf.\n\nCreate your own implementation of `dynamicsqldriver.CredentialsGenerator` and set the username and password portion of\nyour database connection string to `genusername` and `genpassword` respectively. dynamicsqldriver will call your\ngenerator when a new database connection is needed and then replace those values in the connection string before\npassing it along to your favorite SQL driver.\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"database/sql\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/go-sql-driver/mysql\"\n\t\"github.com/google/uuid\"\n\t\"github.com/jaredpetersen/dynamicsqldriver\"\n)\n\n// Generator is an implementation of dynamicsqldriver.CredentialsGenerator that generates credentials and caches them.\ntype Generator struct {\n\tCache dynamicsqldriver.Credentials\n}\n\nfunc (g *Generator) Generate() (dynamicsqldriver.Credentials, error) {\n\tnow := time.Now()\n\tif now.After(g.Cache.Expiration) || now.Equal(g.Cache.Expiration) {\n\t\tg.Cache = dynamicsqldriver.Credentials{\n\t\t\tUsername:   uuid.NewString(),\n\t\t\tPassword:   uuid.NewString(),\n\t\t\tExpiration: now.Add(30 * time.Minute),\n\t\t}\n\t}\n\n\treturn g.Cache, nil\n}\n\nfunc main() {\n\tgenerator := Generator{}\n\n\tdbHost := \"localhost:3306\"\n\tdbName := \"mydb\"\n\n\t// Specify \"genusername\" and \"genpassword\" to have the values replaced by the generator function\n\tdsn := fmt.Sprintf(\"genusername:genpassword@tcp(%s)/%s?parseTime=true\", dbHost, dbName)\n\tdb := sql.OpenDB(dynamicsqldriver.NewConnector(mysql.MySQLDriver{}, \u0026generator, dsn))\n}\n```\n\n## Install\n```shell\ngo get github.com/jaredpetersen/dynamicsqldriver\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredpetersen%2Fdynamicsqldriver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredpetersen%2Fdynamicsqldriver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredpetersen%2Fdynamicsqldriver/lists"}