{"id":43407794,"url":"https://github.com/virgild/mysqlbox","last_synced_at":"2026-02-02T16:17:38.621Z","repository":{"id":66265937,"uuid":"368301167","full_name":"virgild/mysqlbox","owner":"virgild","description":"mysqlbox is a Go library that starts a MySQL server in a Docker container.","archived":false,"fork":false,"pushed_at":"2023-10-30T15:40:33.000Z","size":275,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-20T03:46:35.715Z","etag":null,"topics":["docker","go","mysql","testing"],"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/virgild.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-17T19:33:18.000Z","updated_at":"2021-12-18T01:22:10.000Z","dependencies_parsed_at":"2024-06-20T03:02:09.368Z","dependency_job_id":"1730bf28-0bf6-4620-9499-aed41598385a","html_url":"https://github.com/virgild/mysqlbox","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/virgild/mysqlbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgild%2Fmysqlbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgild%2Fmysqlbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgild%2Fmysqlbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgild%2Fmysqlbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virgild","download_url":"https://codeload.github.com/virgild/mysqlbox/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgild%2Fmysqlbox/sbom","scorecard":{"id":923136,"data":{"date":"2025-08-11","repo":{"name":"github.com/virgild/mysqlbox","commit":"8a1381cd11e12ce3c3ef5fb71dc9b74b680caa31"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/virgild/mysqlbox/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/virgild/mysqlbox/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/virgild/mysqlbox/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/virgild/mysqlbox/codeql-analysis.yml/main?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":9,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29","Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":1,"reason":"9 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-jq35-85cj-fj4p","Warn: Project is vulnerable to: GHSA-mq39-4gv4-mvpx","Warn: Project is vulnerable to: GO-2024-3005 / GHSA-v23v-6jw2-98fq","Warn: Project is vulnerable to: GO-2024-2512 / GHSA-xw73-rw38-6vjc","Warn: Project is vulnerable to: GO-2025-3829 / GHSA-4vq8-7jfc-9cvp","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-25T06:36:39.542Z","repository_id":66265937,"created_at":"2025-08-25T06:36:39.542Z","updated_at":"2025-08-25T06:36:39.542Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29015147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T16:17:30.374Z","status":"ssl_error","status_checked_at":"2026-02-02T15:58:50.469Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["docker","go","mysql","testing"],"created_at":"2026-02-02T16:17:37.882Z","updated_at":"2026-02-02T16:17:38.613Z","avatar_url":"https://github.com/virgild.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mysqlbox\n\n![MySQLBox logo](https://github.com/virgild/mysqlbox/blob/main/static/logo.png?raw=true)\n\n**mysqlbox** creates a ready to use MySQL server in a Docker container that can be\nused in Go tests. The `Start()` function returns a `MySQLBox` that has a container running MySQL server. \nIt has a `Stop()` function that stops the container. The `DB()` function returns a connected \n`sql.DB` that can be used to send queries to MySQL.\n\n\n\n### Install mysqlbox\n\n```sh\ngo get github.com/virgild/mysqlbox\n```\n\n### Basic usage\n\n```go\npackage mytests\n\nimport (\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/virgild/mysqlbox\"\n)\n\nfunc TestMyCode(t *testing.T) {\n\t// Start MySQL container\n\tbox, err := mysqlbox.Start(\u0026mysqlbox.Config{})\n\tif err != nil {\n\t    t.Fatal(err)\n\t}\n\n\t// Register the stop func to stop the container after the test.\n\tt.Cleanup(func() {\n\t    err := box.Stop()\n\t    if err != nil {\n\t        t.Fatal(err)\n\t    }\n\t})\n\t\n\t// Use the box's sql.DB object to query the database.\n\trow := box.MustDB().QueryRow(\"SELECT NOW()\")\n\t\n\tvar now time.Time\n\terr = row.Scan(\u0026row)\n\tif err != nil {\n\t    t.Error(err)\n\t}\n\t\n\tif now.IsZero() {\n\t    t.Error(\"now is zero\")\n\t}\n}\n```\n\n### Other Features\n\n#### Initial script\n\nMySQL server can be started with an initial SQL script that is run after the service starts. It can be provided as an `io.Reader` or a `[]byte` buffer.\n\n##### Specifying the initial script from a file/reader\n\n```go\nschemaFile, err := os.Open(\"testdata/schema.sql\")\nif err != nil {\n    t.Fatal(err)\n}\ndefer schemaFile.Close()\n\nbox, err = mysqlbox.Start(\u0026Config{\n    InitialSQL: mysqlbox.DataFromReader(schemaFile),\n}\nif err != nil {\n    t.Fatal(err)\n}\n\nt.Cleanup(func() {\n    err := b.Stop()\n    if err != nil {\n        t.Fatal(err)\n    }\n})\n```\n\n##### Specifying the initial script from a byte buffer\n\n```go\nsql := []byte(`\n\tCREATE TABLE users\n\t(\n\t\tid         varchar(128) NOT NULL,\n\t\temail      varchar(128) NOT NULL,\n\t\tcreated_at datetime     NOT NULL,\n\t\tupdated_at datetime     NOT NULL,\n\t\tPRIMARY KEY (id),\n\t\tUNIQUE KEY users_email_uindex (email),\n\t\tUNIQUE KEY users_id_uindex (id)\n\t) ENGINE = InnoDB\n\tDEFAULT CHARSET = utf8mb4;\n`)\n\nb, err := mysqlbox.Start(\u0026Config{\n\tInitialSQL: mysqlbox.DataFromBuffer(sql),\n})\nif err != nil {\n\tt.Fatal(err)\n}\nt.Cleanup(func() {\n\terr := b.Stop()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n})\n\nquery := \"INSERT INTO users (id, email, created_at, updated_at) VALUES (?, ?, ?, ?)\"\nnow := time.Now()\n_, err = b.DB().Exec(query, \"U-TEST1\", \"user1@example.com\", now, now)\nif err != nil {\n\tt.Error(err)\n}\n```\n\n#### Cleaning tables\n\nAll tables can be truncated by calling `CleanAllTables()`. This runs `TRUNCATE` on all tables in the database, except for those specified in the `Config.DoNotCleanTables` array. Another function called `CleanTables()` can  be used to truncate just specific tables you want to clean. Any table passed to `CleanTables()` will always truncate it even if it is included in the `DoNotCleanTables` list.\n\n### Using MySQLBox outside tests\n\nIt is not recommended to use MySQLBox as a normal MySQL database. This component is designed to be ephemeral, and no precautions are implemented to protect the database data.\n\n### Troubleshooting and other notes\n\n* I forgot to call `Stop()` and now I have a several containers that are still running.\n\n    The following command can be run to stop the containers started by `MySQLBox`.\n\n    ```sh\n    docker ps -a -f \"label=com.github.virgild.mysqlbox\" --format '{{.ID}}' | xargs docker stop\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirgild%2Fmysqlbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirgild%2Fmysqlbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirgild%2Fmysqlbox/lists"}