Parsing an SQL query into a DOM-like tree to enable auto-permutation?

I have a large and complex sql view that I am trying to debug. There is no record in the view, and I need to determine which sentence or join causes the record. At the moment, I am doing this very manually, deleting sentences one at a time and running a query to see if the required row appears.

I think it would be great if I could do this programmatically, because in the end I immerse myself in such queries about once every two weeks.


Does anyone know if there is a way to parse the SQL query in the object tree (e.g. sqlalchemy.sql.expression ), so I can redo the tree and execute the results?

+4
source share
1 answer

If you don't have a view defined in SQLAlchemy yet, I don't think it can help you.

You can try something like sqlparse that can help you with this. You can transfer its output and perform permutations as raw sql using SQLA.

+3
source

Source: https://habr.com/ru/post/1402284/


All Articles