If you want to extract specific components of a SQL statement for downstream Python tasks, use sqlparse.
In the code above, we use sqlparse to create a structured list of tokens representing different parts of the statement. Subsequently, we extract tables from this list.