rentruewang/inversql

Create SQL that match your selection (with explainable AI), not the other way around

17

stars

31

commits

Cython

primary language

Sep 8, 2026

updated

inversql.rentruewang.com
decision-trees
explainable-ml
scikit-learn
sql
streamlit

README


Unit Testing Pre Commit Checks Publish

PyPI MIT

๐Ÿ”„ InverSQL

Generate SQL that match your selection, with decision trees

  1. User doesn't want to write SQL.
  2. User uploads CSV to inversql streamlit app
  3. User selects cells (that will be selected by the SQL).
  4. We overfit a scikit-learn binary decision tree on the data.
  5. We decompose the tree, convert to boolean logic (explainable AI part).
  6. We simplify the logic with sympy.
  7. Generate SQL from previous steps (joins to JOIN and boolean to WHERE).
  8. User sees the SQL.
  9. User is happy.

๐ŸŽฌ Demo in a GIF๐Ÿ›๏ธ Architecture diagram
Quick Demo Link to live demo site here. Architecture Diagram

๐ŸŽ๏ธ Performance

For each individual SQL query candidate (the shortest one is displayed in the UI), we need to retrain a new decision tree.

But... The decision tree fitting is honestly fast, don't worry about this.

๐ŸŒŸ Give us a star!

That's pretty much it!

If you have read this far, please consider giving me a star (โญ) or a fork (๐Ÿด).

This will keep my motivation going!

Or if you have too much cash at hand: BuyMeACoffee

If you REALLY like my work, nowadays I'm working on aioway, it's an automated training and inference engine that does the following:

  1. Adapt to hardware it runs on (optimal hardware usage)
  2. Adapt to data it trains on (figure out architecture on its own)
  3. Incremental training (never overfit or underfit)

๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ Contributors

Contribution welcome!

To contribute, refer to CONTRIBUTING.md, and our CODE_OF_CONDUCT.md.

๐ŸŽจ Inspiration.

Inspired by regexgen's process. Instead of regex we do SQL. Instead of selecting text we do select records. Decision tree is my inspiration tho.

Contributors

rentruewang

29 commits

HDi98

2 commits

rentruewang/inversql

Create SQL that match your selection (with explainable AI), not the other way around

17

stars

31

commits

Cython

primary language

Sep 8, 2026

updated

inversql.rentruewang.com
decision-trees
explainable-ml
scikit-learn
sql
streamlit

README


Unit Testing Pre Commit Checks Publish

PyPI MIT

๐Ÿ”„ InverSQL

Generate SQL that match your selection, with decision trees

  1. User doesn't want to write SQL.
  2. User uploads CSV to inversql streamlit app
  3. User selects cells (that will be selected by the SQL).
  4. We overfit a scikit-learn binary decision tree on the data.
  5. We decompose the tree, convert to boolean logic (explainable AI part).
  6. We simplify the logic with sympy.
  7. Generate SQL from previous steps (joins to JOIN and boolean to WHERE).
  8. User sees the SQL.
  9. User is happy.

๐ŸŽฌ Demo in a GIF๐Ÿ›๏ธ Architecture diagram
Quick Demo Link to live demo site here. Architecture Diagram

๐ŸŽ๏ธ Performance

For each individual SQL query candidate (the shortest one is displayed in the UI), we need to retrain a new decision tree.

But... The decision tree fitting is honestly fast, don't worry about this.

๐ŸŒŸ Give us a star!

That's pretty much it!

If you have read this far, please consider giving me a star (โญ) or a fork (๐Ÿด).

This will keep my motivation going!

Or if you have too much cash at hand: BuyMeACoffee

If you REALLY like my work, nowadays I'm working on aioway, it's an automated training and inference engine that does the following:

  1. Adapt to hardware it runs on (optimal hardware usage)
  2. Adapt to data it trains on (figure out architecture on its own)
  3. Incremental training (never overfit or underfit)

๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ Contributors

Contribution welcome!

To contribute, refer to CONTRIBUTING.md, and our CODE_OF_CONDUCT.md.

๐ŸŽจ Inspiration.

Inspired by regexgen's process. Instead of regex we do SQL. Instead of selecting text we do select records. Decision tree is my inspiration tho.

Contributors

rentruewang

29 commits

HDi98

2 commits

Languages

Cython

66.0%

Python

31.0%

Makefile

1.6%

Shell

1.4%