Idea: SQL DDL as an input source (optional extra, not core) #71
FabianClemenz
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
💡 Idea: support SQL DDL as an input source — as an optional extra, not in core
Could erdify also read
CREATE TABLE …SQL DDL (alongside the Python ORM sources) and render it to the same ERDs?Architecturally: yes, it fits
erdify's
EntityInfo/FieldInfomodel and the emitters (PlantUML / Mermaid / JSON / HTML) are source-agnostic — the parser is just a frontend. A SQL frontend (CREATE TABLE→EntityInfo) would dock on cleanly.But it must NOT go in the core
Two hard reasons:
ast. Python'sastcan't parse SQL. A hand-rolled SQL parser is a trap — DDL is dialect-chaotic (Postgres/MySQL/SQLite/T-SQL, inline vs. table-level FKs, quoted identifiers, constraints) and would be wrong on real-world schemas. Doing it properly needs a real parser likesqlglot— a genuine dependency.Proposed shape (if pursued)
An optional extra so the core stays zero-dependency:
pip install erdify[sql] # pulls sqlglot only when you want SQL input.sqlfiles become a new source kind, parsed viasqlglotinto the existingEntityInfomodel; everything downstream (formats,--sources,--check, config) is reused.Open questions
*.sql? a--sqlflag pointing at a schema dump)?👉 Thoughts and use cases welcome. Decision so far: keep it out of the zero-dependency core; optional extra at most.
All reactions