{"id":21034396,"url":"https://github.com/zpoint/sql-convertor","last_synced_at":"2025-10-04T08:45:53.993Z","repository":{"id":57470543,"uuid":"286394841","full_name":"zpoint/sql-convertor","owner":"zpoint","description":"convert SQL table defination to peewee/django/... model definition","archived":false,"fork":false,"pushed_at":"2020-09-03T11:15:12.000Z","size":62,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-22T18:59:27.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","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/zpoint.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-10T06:30:50.000Z","updated_at":"2022-10-14T14:51:01.000Z","dependencies_parsed_at":"2022-09-26T17:31:39.642Z","dependency_job_id":null,"html_url":"https://github.com/zpoint/sql-convertor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zpoint/sql-convertor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zpoint%2Fsql-convertor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zpoint%2Fsql-convertor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zpoint%2Fsql-convertor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zpoint%2Fsql-convertor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zpoint","download_url":"https://codeload.github.com/zpoint/sql-convertor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zpoint%2Fsql-convertor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278289475,"owners_count":25962353,"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-10-04T02:00:05.491Z","response_time":63,"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":[],"created_at":"2024-11-19T13:03:59.047Z","updated_at":"2025-10-04T08:45:53.974Z","avatar_url":"https://github.com/zpoint.png","language":"Python","readme":"# sql-convertor\n\nConvert SQL table definition to peewee/django/... model definition\n\nConvert peewee model definition to SQL\n\nConvert django model definition to peewee\n\n![convertor](./convertor.png)\n\n## install\n\n    pip3 install sql-convertor \n\n## usage\n\n    $ convertor --help\n    $ ...\n\n## example\n\n```shell script\n$ echo \"CREATE TABLE \\`t_record\\` ( \\\n\\`c_id\\` INT(64) NOT NULL AUTO_INCREMENT COMMENT '自增主键', \\\nPRIMARY KEY (\\`c_id\\`), \\\nKEY \\`ix_company\\` (\\`c_company_id\\`) USING BTREE \\\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='记录表';\" \u003e 1.sql\n# only support create table definition\n# 只支持建表语句\n# convertor 是程序入口名称\n# sql 是数据来源格式\n# peewee 是输出代码格式\n# 1.sql 是来源文件\n# 用法就是 convertor 源格式 目标格式 来源文件/代码\n$ convertor sql peewee 1.sql\n```\nThe output\n```python3\nclass Record(BaseModel):\n    \"\"\"本段代码由程序从SQL建表语句自动生成, 需要帮助请联系 zp0int@qq.com\"\"\"\n    id = peewee.IntegerField(\n        verbose_name=\"自增主键\",\n        null=False,\n        primary_key=True,\n        column_name=\"c_id\")\n\n    class Meta:\n        table_name = \"t_record\"\n        database = db\n\n    def to_dict(self):\n        return {\n            \"id\": self.id\n        }\n```\n\n```shell script\n$ convertor sql peewee 1.sql out.py\n$ cat out.py\n# output is the same as above\n```\n\n```shell script\n$ convertor sql peewee \"CREATE TABLE \\`t_record\\` ( \\\n    \\`c_id\\` INT(64) NOT NULL AUTO_INCREMENT COMMENT '自增主键', \\\n    PRIMARY KEY (\\`c_id\\`), \\\n    KEY \\`ix_company\\` (\\`c_company_id\\`) USING BTREE \\\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='记录表';\"\n# output is the same as above\n```\n\n## unittest\n\n    sh unittest.sh\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzpoint%2Fsql-convertor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzpoint%2Fsql-convertor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzpoint%2Fsql-convertor/lists"}