{"id":24387973,"url":"https://github.com/funktechno/sql-simple-parser","last_synced_at":"2026-02-09T12:02:14.684Z","repository":{"id":61254857,"uuid":"547075090","full_name":"funktechno/sql-simple-parser","owner":"funktechno","description":"sql ddl parser to support extensions for drawio","archived":false,"fork":false,"pushed_at":"2024-09-16T21:03:53.000Z","size":758,"stargazers_count":0,"open_issues_count":9,"forks_count":1,"subscribers_count":2,"default_branch":"dev","last_synced_at":"2025-07-04T17:19:18.481Z","etag":null,"topics":["drawio","erdiagram","hacktoberfest","mssql","mysql","plugins","postgres","sql","sql-ddl","sql-parser","sqlite"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@funktechno/sqlsimpleparser","language":"TypeScript","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/funktechno.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-10-07T05:07:53.000Z","updated_at":"2024-06-22T23:37:11.000Z","dependencies_parsed_at":"2024-11-15T08:32:29.966Z","dependency_job_id":null,"html_url":"https://github.com/funktechno/sql-simple-parser","commit_stats":{"total_commits":52,"total_committers":2,"mean_commits":26.0,"dds":0.07692307692307687,"last_synced_commit":"09a2d3ea6d98a41900437a8fa829b01c65031b24"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/funktechno/sql-simple-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funktechno%2Fsql-simple-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funktechno%2Fsql-simple-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funktechno%2Fsql-simple-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funktechno%2Fsql-simple-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funktechno","download_url":"https://codeload.github.com/funktechno/sql-simple-parser/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funktechno%2Fsql-simple-parser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269454962,"owners_count":24420263,"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-08-08T02:00:09.200Z","response_time":72,"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":["drawio","erdiagram","hacktoberfest","mssql","mysql","plugins","postgres","sql","sql-ddl","sql-parser","sqlite"],"created_at":"2025-01-19T13:22:20.976Z","updated_at":"2026-02-09T12:02:09.140Z","avatar_url":"https://github.com/funktechno.png","language":"TypeScript","readme":"# sql-simple-parser\nsql ddl parser to support extensions for drawio\n\n## Getting started\n* `npm install --save @funktechno/sqlsimpleparser`\n* how to use:\n```typescript\nimport { SqlSimpleParser } from \"@funktechno/sqlsimpleparser\"\n\nvar sql = `CREATE TABLE \"humanresources_department\" (\n\t\"departmentid\" serial NOT NULL,\n\t\"name\" Name NOT NULL,\n\t\"groupname\" Name NOT NULL,\n\t\"modifieddate\" timestamp NOT NULL,\n\tPRIMARY KEY(\"departmentid\")\n);\n\nCREATE TABLE \"humanresources_employeedepartmenthistory\" (\n  \"businessentityid\" int(4) NOT NULL,\n  \"departmentid\" int(2) NOT NULL,\n  \"shiftid\" int(2) NOT NULL,\n  \"startdate\" date NOT NULL,\n  \"enddate\" date,\n  \"modifieddate\" timestamp NOT NULL,\n  PRIMARY KEY(\"businessentityid\",\"departmentid\",\"shiftid\",\"startdate\"),\n  FOREIGN KEY (\"departmentid\") REFERENCES \"humanresources_department\"(\"departmentid\")\n);\n`\n\n// run parser\nconst parser = new SqlSimpleParser('postgres')\n\n// get models\nconst models = parser\n  .feed(sql)\n  .ToModel();\n```\n* outputs\n```json\n{\n  \"TableList\": [\n    {\n      \"Name\": \"humanresources_department\",\n      \"Properties\": [\n        {\n          \"Name\": \"departmentid\",\n          \"ColumnProperties\": \"serial NOT NULL\",\n          \"TableName\": \"humanresources_department\",\n          \"ForeignKey\": [\n            {\n              \"PrimaryKeyTableName\": \"humanresources_employeedepartmenthistory\",\n              \"PrimaryKeyName\": \"departmentid\",\n              \"ReferencesPropertyName\": \"departmentid\",\n              \"ReferencesTableName\": \"humanresources_department\",\n              \"IsDestination\": true\n            }\n          ],\n          \"IsForeignKey\": false,\n          \"IsPrimaryKey\": true\n        },\n        {\n          \"Name\": \"name\",\n          \"ColumnProperties\": \"Name NOT NULL\",\n          \"TableName\": \"humanresources_department\",\n          \"ForeignKey\": [],\n          \"IsForeignKey\": false,\n          \"IsPrimaryKey\": false\n        },\n        {\n          \"Name\": \"groupname\",\n          \"ColumnProperties\": \"Name NOT NULL\",\n          \"TableName\": \"humanresources_department\",\n          \"ForeignKey\": [],\n          \"IsForeignKey\": false,\n          \"IsPrimaryKey\": false\n        },\n        {\n          \"Name\": \"modifieddate\",\n          \"ColumnProperties\": \"timestamp NOT NULL\",\n          \"TableName\": \"humanresources_department\",\n          \"ForeignKey\": [],\n          \"IsForeignKey\": false,\n          \"IsPrimaryKey\": false\n        }\n      ]\n    },\n    {\n      \"Name\": \"humanresources_employeedepartmenthistory\",\n      \"Properties\": [\n        {\n          \"Name\": \"businessentityid\",\n          \"ColumnProperties\": \"int(4) NOT NULL\",\n          \"TableName\": \"humanresources_employeedepartmenthistory\",\n          \"ForeignKey\": [],\n          \"IsForeignKey\": false,\n          \"IsPrimaryKey\": true\n        },\n        {\n          \"Name\": \"departmentid\",\n          \"ColumnProperties\": \"int(2) NOT NULL\",\n          \"TableName\": \"humanresources_employeedepartmenthistory\",\n          \"ForeignKey\": [\n            {\n              \"PrimaryKeyTableName\": \"humanresources_department\",\n              \"PrimaryKeyName\": \"departmentid\",\n              \"ReferencesPropertyName\": \"departmentid\",\n              \"ReferencesTableName\": \"humanresources_employeedepartmenthistory\",\n              \"IsDestination\": false\n            }\n          ],\n          \"IsForeignKey\": true,\n          \"IsPrimaryKey\": true\n        },\n        {\n          \"Name\": \"shiftid\",\n          \"ColumnProperties\": \"int(2) NOT NULL\",\n          \"TableName\": \"humanresources_employeedepartmenthistory\",\n          \"ForeignKey\": [],\n          \"IsForeignKey\": false,\n          \"IsPrimaryKey\": true\n        },\n        {\n          \"Name\": \"startdate\",\n          \"ColumnProperties\": \"date NOT NULL\",\n          \"TableName\": \"humanresources_employeedepartmenthistory\",\n          \"ForeignKey\": [],\n          \"IsForeignKey\": false,\n          \"IsPrimaryKey\": true\n        },\n        {\n          \"Name\": \"enddate\",\n          \"ColumnProperties\": \"date\",\n          \"TableName\": \"humanresources_employeedepartmenthistory\",\n          \"ForeignKey\": [],\n          \"IsForeignKey\": false,\n          \"IsPrimaryKey\": false\n        },\n        {\n          \"Name\": \"modifieddate\",\n          \"ColumnProperties\": \"timestamp NOT NULL\",\n          \"TableName\": \"humanresources_employeedepartmenthistory\",\n          \"ForeignKey\": [],\n          \"IsForeignKey\": false,\n          \"IsPrimaryKey\": false\n        }\n      ]\n    }\n  ],\n  \"Dialect\": \"postgres\",\n  \"ForeignKeyList\": [\n    {\n      \"PrimaryKeyTableName\": \"humanresources_employeedepartmenthistory\",\n      \"PrimaryKeyName\": \"departmentid\",\n      \"ReferencesPropertyName\": \"departmentid\",\n      \"ReferencesTableName\": \"humanresources_department\",\n      \"IsDestination\": true\n    },\n    {\n      \"PrimaryKeyTableName\": \"humanresources_department\",\n      \"PrimaryKeyName\": \"departmentid\",\n      \"ReferencesPropertyName\": \"departmentid\",\n      \"ReferencesTableName\": \"humanresources_employeedepartmenthistory\",\n      \"IsDestination\": false\n    }\n  ],\n  \"PrimaryKeyList\": [\n    {\n      \"PrimaryKeyTableName\": \"humanresources_department\",\n      \"PrimaryKeyName\": \"departmentid\"\n    },\n    {\n      \"PrimaryKeyTableName\": \"humanresources_employeedepartmenthistory\",\n      \"PrimaryKeyName\": \"businessentityid\"\n    },\n    {\n      \"PrimaryKeyTableName\": \"humanresources_employeedepartmenthistory\",\n      \"PrimaryKeyName\": \"departmentid\"\n    },\n    {\n      \"PrimaryKeyTableName\": \"humanresources_employeedepartmenthistory\",\n      \"PrimaryKeyName\": \"shiftid\"\n    },\n    {\n      \"PrimaryKeyTableName\": \"humanresources_employeedepartmenthistory\",\n      \"PrimaryKeyName\": \"startdate\"\n    }\n  ]\n}\n```\n* there are some [example](./examples) sql files\n* see test `examples_models.spec` for more use cases\n\n## Supported\n* Databases: sqlite, postgres, sqlserver, mysql\n* table names, primary keys, foreign keys, column names with extended column information\n\n## Development\n* `npm install`\n* `npm test` or use vscode debugger **Jest single run**\n\n## Deploy\n* `npm publish --access public`\n* Testing\n  * `npm pack`","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunktechno%2Fsql-simple-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunktechno%2Fsql-simple-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunktechno%2Fsql-simple-parser/lists"}