I am using postgreSQL queries. I want to extract all information from a SQL query, for example
sql = " select d_year, s_nation, p_category, sum(lo_revenue - lo_supplycost) as profit from DATES, CUSTOMER, SUPPLIER, PART, LINEORDER where lo_custkey = c_custkey and lo_suppkey = s_suppkey and lo_partkey = p_partkey and lo_orderdate = d_datekey and c_region = 'AFRICA' and s_region = 'AFRICA' and (d_year = 1996 or d_year = 1997) and (p_mfgr = 'MFGR#2' or p_mfgr = 'MFGR#4') group by d_year, s_nation, p_category order by d_year, s_nation, p_category "
I want to get all tables concerned, all selection predicate, and all join predicate, group by part, and order by part.
I used sqlparse
and I found a way to get only the tables concerned.
Is there any examples of how to extract this information?