{"id":13670866,"url":"https://github.com/mmzp/sql-parser","last_synced_at":"2026-02-09T02:08:51.014Z","repository":{"id":48306919,"uuid":"211293883","full_name":"mmzp/sql-parser","owner":"mmzp","description":"解析 mysql create table 语句，用于通过建表语句生成 model 代码文件。","archived":false,"fork":false,"pushed_at":"2021-08-02T13:35:55.000Z","size":126,"stargazers_count":25,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-14T21:12:21.413Z","etag":null,"topics":["browser","mysql","nearley","nodejs","sql-parser"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmzp.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":"2019-09-27T10:22:30.000Z","updated_at":"2025-01-05T09:27:43.000Z","dependencies_parsed_at":"2022-08-25T09:41:28.916Z","dependency_job_id":null,"html_url":"https://github.com/mmzp/sql-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mmzp/sql-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmzp%2Fsql-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmzp%2Fsql-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmzp%2Fsql-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmzp%2Fsql-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmzp","download_url":"https://codeload.github.com/mmzp/sql-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmzp%2Fsql-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29254307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T01:52:29.835Z","status":"online","status_checked_at":"2026-02-09T02:00:09.501Z","response_time":56,"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":["browser","mysql","nearley","nodejs","sql-parser"],"created_at":"2024-08-02T09:00:51.179Z","updated_at":"2026-02-09T02:08:50.999Z","avatar_url":"https://github.com/mmzp.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# sql-parser\n\n解析 mysql create table 语句，用于通过建表语句生成 model 代码文件。\n\n```\nyarn install @mmzp/sql-parser\nyarn dev\n```\n\n或\n\n```\nnpm i @mmzp/sql-parser\nnpm run dev\n```\n\n```\n// 构建支持浏览器环境的代码文件，浏览器端直接引用构建出来的 browser/sql-parser.min.js 文件即可，browser/demo.html 为调用示例\n\nyarn browser\n或\nnpm run browser\n```\n\n[在线示例 https://mmzp.github.io/sql-parser/browser/demo.html](https://mmzp.github.io/sql-parser/browser/demo.html)\n\n---\n\n解析结果如下：\n\n```json\n[\n    {\n        \"type\": \"create_table\",\n        \"name\": \"tbl1\",\n        \"columns\": [\n            {\n                \"type\": \"column\",\n                \"name\": \"id\",\n                \"data_type\": {\n                    \"type\": \"INT\",\n                    \"params\": [10],\n                    \"unsigned\": true\n                },\n                \"allow_null\": false,\n                \"comment\": \"\",\n                \"auto_increment\": true\n            },\n            {\n                \"type\": \"column\",\n                \"name\": \"name\",\n                \"data_type\": {\n                    \"type\": \"VARCHAR\",\n                    \"params\": [50]\n                },\n                \"allow_null\": true,\n                \"comment\": \"\",\n                \"default_value\": \"\"\n            },\n            {\n                \"type\": \"column\",\n                \"name\": \"weight\",\n                \"data_type\": {\n                    \"type\": \"DECIMAL\",\n                    \"params\": [5, 2]\n                },\n                \"allow_null\": true,\n                \"comment\": \"\"\n            },\n            {\n                \"type\": \"column\",\n                \"name\": \"roles_BIT\",\n                \"data_type\": {\n                    \"type\": \"BIT\",\n                    \"params\": [10]\n                },\n                \"allow_null\": true,\n                \"comment\": \"\"\n            },\n            {\n                \"type\": \"column\",\n                \"name\": \"size\",\n                \"data_type\": {\n                    \"type\": \"ENUM\",\n                    \"params\": [\"x-small\", \"small\", \"medium\", \"large\", \"x-large\"]\n                },\n                \"allow_null\": true,\n                \"comment\": [\"尺寸\"]\n            },\n            {\n                \"type\": \"column\",\n                \"name\": \"type\",\n                \"data_type\": {\n                    \"type\": \"TINYINT\",\n                    \"params\": [3],\n                    \"unsigned\": true\n                },\n                \"allow_null\": false,\n                \"comment\": \"客户端类型，0：未知；1：微信小程序；\",\n                \"default_value\": 0\n            },\n            {\n                \"type\": \"column\",\n                \"name\": \"t\",\n                \"data_type\": {\n                    \"type\": \"TIMESTAMP\"\n                },\n                \"allow_null\": false,\n                \"comment\": \"\",\n                \"default_value\": \"CURRENT_TIMESTAMP\"\n            },\n            {\n                \"type\": \"column\",\n                \"name\": \"url\",\n                \"data_type\": {\n                    \"type\": \"VARCHAR\",\n                    \"params\": [255]\n                },\n                \"allow_null\": false,\n                \"comment\": \"地址\",\n                \"default_value\": \"\",\n                \"charset\": \"utf8\"\n            },\n            {\n                \"type\": \"primary_key\",\n                \"fields\": [\"id\"]\n            },\n            {\n                \"type\": \"unique_key\",\n                \"name\": \"uniq_name\",\n                \"fields\": [\"name\"]\n            },\n            {\n                \"type\": \"index_key\",\n                \"name\": \"idx_app_id\",\n                \"fields\": [\"app_id\", \"id\"]\n            }\n        ],\n        \"options\": [\n            {\n                \"key\": \"ENGINE\",\n                \"value\": \"InnoDB\"\n            },\n            {\n                \"key\": \"AUTO_INCREMENT\",\n                \"value\": 2\n            },\n            {\n                \"key\": \"CHARSET\",\n                \"value\": \"utf8mb4\"\n            },\n            {\n                \"key\": \"COMMENT\",\n                \"value\": \"应用表\"\n            }\n        ]\n    }\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmzp%2Fsql-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmzp%2Fsql-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmzp%2Fsql-parser/lists"}