{"id":23118991,"url":"https://github.com/tusharad/sql2er","last_synced_at":"2025-08-17T00:31:47.712Z","repository":{"id":261917441,"uuid":"882762138","full_name":"tusharad/sql2er","owner":"tusharad","description":"Generate ER-diagram using SQL file","archived":false,"fork":false,"pushed_at":"2024-12-31T10:38:08.000Z","size":1405,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T20:45:16.537Z","etag":null,"topics":["er-diagram","haskell","postgresql","sql"],"latest_commit_sha":null,"homepage":"https://tusharad.github.io/sql2er/","language":"Haskell","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/tusharad.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-11-03T17:37:16.000Z","updated_at":"2025-03-30T10:32:21.000Z","dependencies_parsed_at":"2024-11-09T08:35:05.638Z","dependency_job_id":"df3d5500-b230-4480-a883-a3ac951d542a","html_url":"https://github.com/tusharad/sql2er","commit_stats":null,"previous_names":["tusharad/sql2er"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tusharad/sql2er","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusharad%2Fsql2er","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusharad%2Fsql2er/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusharad%2Fsql2er/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusharad%2Fsql2er/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tusharad","download_url":"https://codeload.github.com/tusharad/sql2er/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusharad%2Fsql2er/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270791255,"owners_count":24645781,"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-16T02:00:11.002Z","response_time":91,"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":["er-diagram","haskell","postgresql","sql"],"created_at":"2024-12-17T05:31:01.698Z","updated_at":"2025-08-17T00:31:47.698Z","avatar_url":"https://github.com/tusharad.png","language":"Haskell","readme":"[![Contributors][contributors-shield]][contributors-url]  \n[![Forks][forks-shield]][forks-url]  \n[![Stargazers][stars-shield]][stars-url]  \n[![Issues][issues-shield]][issues-url]  \n[![MIT License][license-shield]][license-url]  \n[![LinkedIn][linkedin-shield]][linkedin-url]  \n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cdiv align=\"center\" id=\"readme-top\"\u003e\n  \u003ca href=\"https://github.com/tusharad/sql2er\"\u003e\n    \u003cimg src=\"example/logo.jpeg\" alt=\"Logo\" width=\"180\" height=\"180\"\u003e\n  \u003c/a\u003e\n\n  \u003ch1 align=\"center\"\u003eSQL 2 ER\u003c/h1\u003e\n\n  \u003cp align=\"center\"\u003e\n    A command-line tool to convert SQL scripts into Entity-Relationship (ER) diagrams.\n    \u003cbr\u003e\n    Designed to work with PostgreSQL syntax.\n    \u003cbr\u003e\n    \u003ca href=\"https://github.com/tusharad/sql2er/issues/new?labels=bug\u0026template=bug-report---.md\"\u003e\u003cstrong\u003eReport a Bug\u003c/strong\u003e\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/tusharad/sql2er/issues/new?labels=enhancement\u0026template=feature-request---.md\"\u003e\u003cstrong\u003eRequest a Feature\u003c/strong\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n---\n\n## Table of Contents\n\n- [Example](#example)  \n- [Getting Started](#getting-started)  \n- [Built With](#built-with)  \n- [Roadmap](#roadmap)  \n- [Limitations](#limitations)  \n- [Unsupported Features](#unsupported-features)  \n- [Acknowledgments](#acknowledgments)\n\n---\n## [Checkout](https://tusharad.github.io/sql2er/) web version powered by WebAssembly\n\n\n## Example\n\n**Input: `test.sql`**\n\n```sql\nbegin;\n\ncreate table users (\n\tuser_id serial primary key\n  , user_name varchar(255) not null unique\n  , email varchar(255) not null unique\n  , password text not null\n  , created_at timestamptz default now()\n  , updated_at timestamptz default now()\n);\n\ncreate table user_profile_image (\n\tuser_id int references users on delete cascade primary key\n ,  user_profile_image text not null\n ,  created_at timestamptz default now()\n ,  updated_at timestamptz default now()\n);\n...\n```\n\n**Command:**\n\n```bash\n./sql2er-exe test.sql -o erd.jpeg\n```\n\n**Output:**\n\n\u003cimg src=\"example/erd.jpeg\" alt=\"ER Diagram\" width=\"100%\" height=\"580\"\u003e\n\n---\n\n## Getting Started\n\n### Option 1: Download Binary\n\n1. Download the binary from the [Releases](https://github.com/tusharad/sql2er/releases) page.\n2. Run the tool:\n\n    ```bash\n    ./sql2er-exe test.sql -o erd.jpeg\n    ```\n\n### Option 2: Build from Source\n\n1. Install [Stack](https://docs.haskellstack.org/en/stable/) via [GHCup](https://www.haskell.org/ghcup/).\n2. Clone the repository and navigate to the project root.\n3. Build the binary for linux:\n\n    ```bash\n    stack build\n    cp $(stack path --local-install-root)/bin/sql2er-exe .\n    ./sql2er-exe test.sql -o erd.jpeg\n    ```\n\n### Option 3: Build WASM\n\n1. Install `wasm32-wasi-cabal` from [here](https://gitlab.haskell.org/ghc/ghc-wasm-meta)\n2. Make sure to download the `9.8` `FLAVOUR`.\n\n```bash\nwasm32-wasi-cabal build sql2er-wasm -f build-sql2er-wasm\ncp path/to/sql2er-wasm.wasm .\npython3 -m http.server\n```\n\n---\n\n## Built With\n\n[![Haskell][Haskell]][Haskell-url]\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n---\n\n## Roadmap\n\n- [x] Add Changelog  \n- [x] Add Test Cases  \n- [x] Support `GENERATED` Constraint  \n- [x] Gracefully Ignore Partitions  \n- [x] Support `bigserial`  \n- [ ] Add Additional Examples  \n- [ ] Enhance Documentation  \n- [ ] Add More Parsing Functions  \n- [ ] Support Interval Data Type  \n- [ ] Support 2D Arrays  \n\nFor the full list of proposed features and known issues, check out the [open issues](https://github.com/tusharad/sql2er/issues).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n---\n\n## Limitations\n\n- Needs internet connection since, We are sending request to mermaid API.\n- **Syntax Validation:**  \n  The parser doesn't validate SQL syntax; it extracts only the necessary information for generating ER diagrams.  \n- **PostgreSQL Specific:**  \n  Designed and tested using PostgreSQL 17.  \n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n---\n\n## Unsupported Features\n\n- `DETACH`  \n- `USING ...`  \n- `TABLESPACE`  \n- `NOT VALID`  \n- `VALIDATE`  \n- `INTERVAL` Data Type  \n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n---\n\n## Acknowledgments\n\nThis project was inspired by [sqldiagram](https://github.com/RadhiFadlillah/sqldiagram), which focuses on MySQL but lacked robust parsing capabilities.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/tusharad/sql2er.svg?style=for-the-badge\n[contributors-url]: https://github.com/tusharad/sql2er/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/tusharad/sql2er.svg?style=for-the-badge\n[forks-url]: https://github.com/tusharad/sql2er/network/members\n[stars-shield]: https://img.shields.io/github/stars/tusharad/sql2er.svg?style=for-the-badge\n[stars-url]: https://github.com/tusharad/sql2er/stargazers\n[issues-shield]: https://img.shields.io/github/issues/tusharad/sql2er.svg?style=for-the-badge\n[issues-url]: https://github.com/tusharad/sql2er/issues\n[license-shield]: https://img.shields.io/github/license/tusharad/sql2er.svg?style=for-the-badge\n[license-url]: https://github.com/tusharad/sql2er/blob/main/LICENSE.txt\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n[linkedin-url]: https://linkedin.com/in/tushar-adhatrao\n[Haskell]: https://img.shields.io/badge/Haskell-5e5086?style=for-the-badge\u0026logo=haskell\u0026logoColor=white\n[Haskell-url]: https://www.haskell.org/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftusharad%2Fsql2er","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftusharad%2Fsql2er","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftusharad%2Fsql2er/lists"}