{"id":41756179,"url":"https://github.com/liangyaopei/sqltogo","last_synced_at":"2026-01-25T01:37:01.498Z","repository":{"id":57541281,"uuid":"277819148","full_name":"liangyaopei/sqltogo","owner":"liangyaopei","description":"Golang converts  a sql create statement to a go struct, saving to time of manually writing template code","archived":false,"fork":false,"pushed_at":"2020-07-31T14:25:45.000Z","size":121,"stargazers_count":21,"open_issues_count":0,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T03:56:40.926Z","etag":null,"topics":["golang","parse","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/liangyaopei.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}},"created_at":"2020-07-07T13:07:11.000Z","updated_at":"2024-04-18T04:58:05.000Z","dependencies_parsed_at":"2022-09-26T18:30:45.923Z","dependency_job_id":null,"html_url":"https://github.com/liangyaopei/sqltogo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/liangyaopei/sqltogo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liangyaopei%2Fsqltogo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liangyaopei%2Fsqltogo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liangyaopei%2Fsqltogo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liangyaopei%2Fsqltogo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liangyaopei","download_url":"https://codeload.github.com/liangyaopei/sqltogo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liangyaopei%2Fsqltogo/sbom","scorecard":{"id":587642,"data":{"date":"2025-08-11","repo":{"name":"github.com/liangyaopei/sqltogo","commit":"af2d63df23d07d0732ece543f948003d8a93dcac"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Code-Review","score":0,"reason":"Found 0/5 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":"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":"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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 'master'"],"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"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-20T20:59:14.013Z","repository_id":57541281,"created_at":"2025-08-20T20:59:14.013Z","updated_at":"2025-08-20T20:59:14.013Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28740977,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T01:25:41.653Z","status":"ssl_error","status_checked_at":"2026-01-25T01:25:34.364Z","response_time":89,"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":["golang","parse","sql"],"created_at":"2026-01-25T01:37:01.441Z","updated_at":"2026-01-25T01:37:01.490Z","avatar_url":"https://github.com/liangyaopei.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/liangyaopei/sqltogo)](https://goreportcard.com/report/github.com/liangyaopei/sqltogo)\n[![GoDoc](https://godoc.org/github.com/liangyaopei/sqltogo?status.svg)](http://godoc.org/github.com/liangyaopei/sqltogo)\n[中文版说明](./README_zh.md)\n\n## Description\nThis repository provide a way to convert SQL create statement to Golang struct (ORM struct) by parsing the SQL statement.\nFor example, with the input\n```mysql\nCREATE TABLE `USER`(\n    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'primary key',\n    `ip_address` INT  NOT NULL DEFAULT 0 COMMENT 'ip_address',\n    `nickname`    VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'user note',\n    `description` VARCHAR(256) NOT NULL DEFAULT '' COMMENT 'user description',\n    `creator_email` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'creator email',\n    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',\n    `deleted_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'delete time',\n    PRIMARY KEY(`id`)\n)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='user table';\n```\nthe function `SqlToGo` will convert it to as follow, with the `package` name is optional.\n```go\npackage sql_to_go_test\n\nimport (\n\t\"time\"\n)\n\ntype USER struct {\n\tId           uint      `comment:\"primary key\"`\n\tIpAddress    int       `comment:\"ip_address\"`\n\tNickname     string    `comment:\"user note\"`\n\tDescription  string    `comment:\"user description\"`\n\tCreatorEmail string    `comment:\"creator email\"`\n\tCreatedAt    time.Time `comment:\"create time\"`\n\tDeletedAt    time.Time `comment:\"delete time\"`\n}\n```\n\n## Snake case To Camel case\nIn SQL, the naming convention of a filed is snake case, such as `ip_address`, while in Golang, \nthe naming convention of struct's field is Camel case. So the `SqlToGo` function will convert snake case to\nCamel case.\n\n## Test \u0026 run\nThe test will read the sample sql from `input.sql`, and print the output, then `gofmt` it and save\nthe result in `_output.go`\n```sh\ncd sql_to_go_test\ngo test -v .\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliangyaopei%2Fsqltogo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliangyaopei%2Fsqltogo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliangyaopei%2Fsqltogo/lists"}