{"slug": "show-hn-inversql-build-sql-interactively-in-inverse", "title": "Show HN: InverSQL: Build SQL interactively in inverse", "summary": "Developer rentruewang released InverSQL, an open-source Streamlit app that generates SQL queries from CSV uploads by overfitting a scikit-learn decision tree, converting it to boolean logic with sympy, and simplifying it into SQL. The tool, demonstrated at inversql.streamlit.app, lets users select cells to define query results without writing SQL, and the author is also promoting a related project, aioway, an automated training and inference engine.", "body_md": "1. User doesn't want to write SQL.\n2. User uploads CSV to [inversql streamlit app](https://inversql.streamlit.app)\n3. User selects cells (that will be selected by the SQL).\n4. We **overfit** a`scikit-learn` binary decision tree on the data.\n5. We decompose the tree, convert to boolean logic (explainable AI part).\n6. We simplify the logic with `sympy` .\n7. Generate SQL from previous steps (joins to JOIN and boolean to WHERE).\n8. User sees the SQL.\n9. User is happy.\n\n| 🎬 Demo in a GIF | 🏛️ Architecture diagram | \n|---|---|\n|                 [Link to](/rentruewang/inversql/blob/main/assets/quick-demo.gif)                    [live demo site](https://inversql.streamlit.app)         here. |   | \n\nFor each individual SQL query candidate (the shortest one is displayed in the UI), we need to retrain a new decision tree.\n\nBut... The decision tree fitting is honestly fast, don't worry about this.\n\nThat's pretty much it!\n\nIf you have read this far, please consider giving me a [star (⭐)](https://github.com/rentruewang/inversql/stargazers) or a fork (🍴).\n\nThis will keep my motivation going!\n\nOr if you have too much cash at hand: \n\nIf you **REALLY** like my work, nowadays I'm working on [`aioway`](https://github.com/rentruewang/aioway),\nit's an automated training and inference engine that does the following:\n\n- Adapt to hardware it runs on (optimal hardware usage)\n- Adapt to data it trains on (figure out architecture on its own)\n- Incremental training (never overfit or underfit)\n\nContribution welcome!\n\nTo contribute, refer to [CONTRIBUTING.md](/rentruewang/inversql/blob/main/CONTRIBUTING.md),\nand our [CODE_OF_CONDUCT.md](/rentruewang/inversql/blob/main/CODE_OF_CONDUCT.md).\n\nInspired by [regexgen](https://github.com/devongovett/regexgen#how-does-it-work)'s process. Instead of regex we do SQL. Instead of selecting text we do select records. Decision tree is my inspiration tho.", "url": "https://wpnews.pro/news/show-hn-inversql-build-sql-interactively-in-inverse", "canonical_source": "https://github.com/rentruewang/inversql", "published_at": "2026-09-08 16:44:14+00:00", "updated_at": "2026-09-08 16:57:54.425642+00:00", "lang": "en", "topics": ["developer-tools", "machine-learning", "artificial-intelligence"], "entities": ["rentruewang", "InverSQL", "Streamlit", "scikit-learn", "sympy", "aioway"], "alternates": {"html": "https://wpnews.pro/news/show-hn-inversql-build-sql-interactively-in-inverse", "markdown": "https://wpnews.pro/news/show-hn-inversql-build-sql-interactively-in-inverse.md", "text": "https://wpnews.pro/news/show-hn-inversql-build-sql-interactively-in-inverse.txt", "jsonld": "https://wpnews.pro/news/show-hn-inversql-build-sql-interactively-in-inverse.jsonld"}}