{"id":21090676,"url":"https://github.com/ycrao/ddl-to-object","last_synced_at":"2026-04-10T20:43:37.160Z","repository":{"id":64303077,"uuid":"491440092","full_name":"ycrao/ddl-to-object","owner":"ycrao","description":"DDL to Object","archived":false,"fork":false,"pushed_at":"2023-09-12T08:44:54.000Z","size":68,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-16T03:08:41.432Z","etag":null,"topics":["curd","data-type-mapper","ddl","generator","language","mysql","object","php","script-tools","sql","sql-data-type"],"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/ycrao.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":"2022-05-12T09:05:32.000Z","updated_at":"2024-03-10T18:04:23.000Z","dependencies_parsed_at":"2024-06-20T04:41:48.754Z","dependency_job_id":null,"html_url":"https://github.com/ycrao/ddl-to-object","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ycrao/ddl-to-object","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycrao%2Fddl-to-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycrao%2Fddl-to-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycrao%2Fddl-to-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycrao%2Fddl-to-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ycrao","download_url":"https://codeload.github.com/ycrao/ddl-to-object/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycrao%2Fddl-to-object/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267464522,"owners_count":24091505,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["curd","data-type-mapper","ddl","generator","language","mysql","object","php","script-tools","sql","sql-data-type"],"created_at":"2024-11-19T21:39:14.005Z","updated_at":"2026-04-10T20:43:37.146Z","avatar_url":"https://github.com/ycrao.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ddl-to-object\n\n[![GoVersion](https://img.shields.io/github/go-mod/go-version/ycrao/ddl-to-object)](https://github.com/ycrao/ddl-to-object/blob/master/go.mod)\n[![Release](https://img.shields.io/github/v/release/ycrao/ddl-to-object)](https://github.com/ycrao/ddl-to-object/releases)\n![Stars](https://img.shields.io/github/stars/ycrao/ddl-to-object)\n[![MIT license](https://img.shields.io/github/license/ycrao/ddl-to-object)](https://opensource.org/licenses/MIT)\n[![OpenIssue](https://img.shields.io/github/issues/ycrao/ddl-to-object)](https://github.com/ycrao/ddl-to-object/issues?q=is%3Aopen+is%3Aissue)\n\n[SimplifiedChinese README/简体中文读我](./README_zh-CN.md)\n\nddl-to-object: a tool help to generate object files in different languages from sql ddl file.\n\n## Database supports\n\n- only tested for MySQL/MariaDB DDL SQL\n\n## Language supports\n\nPR is welcome! You can do some coding stuff to support another language.\n\n- java: generate entity class with auto snake_style to camelStyle naming in properties, bring comments, using lombok plugin for getter/setter, with package directory support\n- golang: generate to struct with tags and comments\n- php: generate to simple class with namespace and comments support\n- python: generate to simple object with comments support\n- support any other program language?: pull request is welcome\n\n## Best practice\n\n- A good-designed pattern in MySQL DDL, such as using singular nouns as table and column name, naming in `snake_case` style, with more comments, no table prefix, having a primary key etc.\n- The rest, just using this tool to help you generate target language object files\n\n## Installation\n\n### Quick Install (Recommended)\n\n**One-line install for Linux/macOS:**\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/ycrao/ddl-to-object/main/install-online.sh | bash\n```\n\nThis will automatically:\n\n- Detect your system (Linux/macOS)\n- Download the latest release\n- Install to `~/.local/bin/ddl-to-object`\n- Set up templates and config in `~/.dto/`\n- Update your PATH\n\n### Manual Install\n\n1. Download the appropriate file from [Releases](https://github.com/ycrao/ddl-to-object/releases/latest):\n   - Linux: `ddl-to-object-linux-*.tar.gz`\n   - macOS (Intel): `ddl-to-object-mac-*.tar.gz`\n   - macOS (ARM64): `ddl-to-object-mac-arm64-*.tar.gz`\n   - Windows: `ddl-to-object-windows-*.zip`\n\n2. Extract and install:\n\n   ```bash\n   tar -xzf ddl-to-object-*.tar.gz\n   sudo cp */ddl-to-object /usr/local/bin/\n   mkdir -p ~/.dto\n   cp -r */template ~/.dto/\n   cp */config.json ~/.dto/\n   ```\n\n### Verify Installation\n\n```bash\nddl-to-object version\nddl-to-object --help\n```\n\n## Command helps\n\n```bash\n  ddl-to-object go         Generate golang target object file\n  ddl-to-object java       Generate java target object file\n  ddl-to-object php        Generate php target object file\n  ddl-to-object python     Generate python target object file\n  -c, --config string   config file path (default: ~/.dto/config.json)\n  -f, --from path       from path which a single-table DDL file located\n  -n, --ns namespace    namespace name for php, only in php command (default: App\\Models)\n  -p, --pk package      package name, only in java or go command (default: com.example.sample.domain.entity)\n  -s, --stdout          enable stdout or not, default set false to disable\n  -t, --to path         output to target path or location, create directory automatically if it not existed\n  -v, --verbose         enable verbose output\n      --dry-run         show what would be generated without creating files\n```\n\n## Usage examples\n\n```bash\nddl-to-object php -f ./output/samples/example_3.ddl.txt -n Modules\\\\Blog\\\\Models -t ./output/php/\nddl-to-object java -f ./output/samples/example_2.ddl.txt -p com.douyasi.sample.domain.entity -t ./output/java/\nddl-to-object go -f ./output/samples/example_3.ddl.txt -p models -t ./output/go/\n```\n\n## Output examples\n\nSee output directory.\n\n- [java](./output/java/Article.java)\n- [golang](./output/go/article_types.go)\n- [php](./output/php/Article.php)\n- [python](./output/python/article.py)\n\n## How to modify templates\n\nAs installation intro, default template files located in `~/.dto/template` directory (note: `~` for current user home workdir; if they're not existed, you need copy them by yourself manually).\n\nThe template is a raw text by using golang [text/template](https://pkg.go.dev/text/template) with `ParsedResult` type struct passed in. You can modify them as you can.\n\n## Known so-called bugs\n\n- not work well in one-line DDL SQL\n- not work well with mixed style (such as snake_style, camelStyle, PascalStyle and other cases mixed) in DDL SQL\n- special table or field name, such as `365Days_table`, `1st_field` and `biz.error.code.field` etc \n- some MySQL data type may not mapper well to Java or Golang data type\n- some unused imports in Java and Golang, you can clean them by yourself or using some tool like `gofmt`\n- lack of some special testing cases\n\n## Configuration\n\nYou can create a configuration file to customize default settings. Configuration file location: `~/.dto/config.json`\n\nExample configuration:\n\n```json\n{\n  \"default_packages\": {\n    \"go\": \"models\",\n    \"java\": \"com.yourcompany.domain.entity\",\n    \"php\": \"App\\\\Models\",\n    \"python\": \"\"\n  },\n  \"template_dir\": \"~/.dto/template\",\n  \"log_level\": \"info\",\n  \"output_settings\": {\n    \"create_directories\": true,\n    \"overwrite_files\": true,\n    \"backup_existing\": false\n  }\n}\n```\n\n## New Features\n\n- **Improved error handling**: Better error messages and validation\n- **Configuration file support**: Customize default packages and settings\n- **Verbose mode**: Use `-v` flag for detailed output\n- **Dry-run mode**: Use `--dry-run` to preview what would be generated\n- **Backup functionality**: Optional backup of existing files\n- **Better logging**: Leveled log output\n- **Version information**: Detailed build information\n\n## Building\n\nUse the provided Makefile:\n\n```bash\n# Build for single platform\nmake build\n\n# Build for all platforms\nmake build-all\n\n# Run tests\nmake test\n\n# Format code\nmake fmt\n```\n\n## Similar projects and references\n\n- [liangyaopei/sqltogo](https://github.com/liangyaopei/sqltogo)\n- [xwb1989/sqlparser](https://github.com/xwb1989/sqlparser)\n- [nao1215/ddl-maker](https://github.com/nao1215/ddl-maker)\n- [zeromicro/ddl-parser](https://github.com/zeromicro/ddl-parser)\n- [blastrain/vitess-sqlparser](https://github.com/blastrain/vitess-sqlparser)\n- [json-to-go](https://mholt.github.io/json-to-go/)\n- [curl-to-go](https://mholt.github.io/curl-to-go/)\n- [sql-to-go-struct-java-class-json-format](https://plugins.jetbrains.com/plugin/17336-sql-to-go-struct-java-class-json-format)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fycrao%2Fddl-to-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fycrao%2Fddl-to-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fycrao%2Fddl-to-object/lists"}