{"id":37101187,"url":"https://github.com/chixm/db2struct","last_synced_at":"2026-01-14T12:18:02.064Z","repository":{"id":57539235,"uuid":"287657845","full_name":"chixm/db2struct","owner":"chixm","description":"Converts a mysql table into a golang struct","archived":false,"fork":true,"pushed_at":"2020-08-17T07:43:41.000Z","size":1145,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T05:14:02.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Shelnutt2/db2struct","license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chixm.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-08-15T01:43:42.000Z","updated_at":"2020-08-17T07:43:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/chixm/db2struct","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/chixm/db2struct","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chixm%2Fdb2struct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chixm%2Fdb2struct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chixm%2Fdb2struct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chixm%2Fdb2struct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chixm","download_url":"https://codeload.github.com/chixm/db2struct/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chixm%2Fdb2struct/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"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":[],"created_at":"2026-01-14T12:18:01.256Z","updated_at":"2026-01-14T12:18:02.054Z","avatar_url":"https://github.com/chixm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# db2struct [![Build Status](https://travis-ci.org/Shelnutt2/db2struct.svg?branch=master)](https://travis-ci.org/Shelnutt2/db2struct) [![Coverage Status](https://coveralls.io/repos/github/Shelnutt2/db2struct/badge.svg?branch=1-add-coveralls-support)](https://coveralls.io/github/Shelnutt2/db2struct?branch=1-add-coveralls-support) [![GoDoc](https://godoc.org/github.com/Shelnutt2/db2struct?status.svg)](https://godoc.org/github.com/Shelnutt2/db2struct)\n\nThe db2struct package produces a usable golang struct from a given database table for use in a .go file.\n\nBy reading details from the database about the column structure, db2struct generates a go compatible struct type\nwith the required column names, data types, and annotations.\n\nGenerated datatypes include support for nullable columns [sql.NullX types](https://golang.org/pkg/database/sql/#NullBool) or [guregu null.X types](https://github.com/guregu/null)\nand the expected basic built in go types.\n\nDb2Struct is based/inspired by the work of ChimeraCoder's gojson package\n[gojson](https://github.com/ChimeraCoder/gojson)\n\n\n\n## Usage\n\n```BASH\ngo get github.com/Shelnutt2/db2struct/cmd/db2struct\ndb2struct --host localhost -d test -t test_table --package myGoPackage --struct testTable -p --user testUser\n```\n\n## Example\n\nMySQL table named users with four columns: id (int), user_name (varchar(255)), number_of_logins (int(11),nullable), and LAST_NAME (varchar(255), nullable)  \n\nExample below uses guregu's null package, but without the option it procuded the sql.NullInt64 and so on.\n```BASH\ndb2struct --host localhost -d example.com -t users --package example --struct user -p --user exampleUser --guregu --gorm\n```\n\nOutput:\n```GOLANG\n\npackage example\n\ntype User struct {\n  ID              int   `gorm:\"column:id\"`\n  UserName        string `gorm:\"column:user_name\"`\n  NumberOfLogins  null.Int `gorm:\"column:number_of_logins\"`\n  LastName        null.String `gorm:\"column:LAST_NAME\"`\n}\n```\n\n## Supported Databases\n\nCurrently Supported\n-   MariaDB\n-   MySQL\n\nPlanned Support\n-   PostgreSQL\n-   Oracle\n-   Microsoft SQL Server\n\n### MariaDB/MySQL\n\nStructures are created by querying the INFORMATION_SCHEMA.Columns table and then formatting the types, column names,\nand metadata to create a usable go compatible struct type.\n\n#### Supported Datatypes\n\nCurrently only a limited number of MariaDB/MySQL datatypes are supported. Initial support includes:\n-   tinyint (sql.NullInt64 or null.Int)\n-   int      (sql.NullInt64 or null.Int)\n-   smallint      (sql.NullInt64 or null.Int)\n-   mediumint      (sql.NullInt64 or null.Int)\n-   bigint (sql.NullInt64 or null.Int)\n-   decimal (sql.NullFloat64 or null.Float)\n-   float (sql.NullFloat64 or null.Float)\n-   double (sql.NullFloat64 or null.Float)\n-   datetime (null.Time)\n-   time  (null.Time)\n-   date (null.Time)\n-   timestamp (null.Time)\n-   var (sql.String or null.String)\n-   enum (sql.String or null.String)\n-   varchar (sql.String or null.String)\n-   longtext (sql.String or null.String)\n-   mediumtext (sql.String or null.String)\n-   text (sql.String or null.String)\n-   tinytext (sql.String or null.String)\n-   binary\n-   blob\n-   longblob\n-   mediumblob\n-   varbinary\n-   json\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchixm%2Fdb2struct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchixm%2Fdb2struct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchixm%2Fdb2struct/lists"}