I need to capture only the where
clause of multiple queries to parse the filters used.
For example:
select "DIM_1"."col1",
"DIM_2"."col2" ,
"DIM_3"."col3" ,
"DIM_4"."col4" ,
"FAT_1"."col5"
from "FAT_1",
"DIM_1",
"DIM_2",
"DIM_3",
"DIM_4"
where "DIM_1"."col1" IS NOT NULL
AND "DIM_2"."col2" LIKE ('SUCCESS')
AND "DIM_3"."col3" BETWEEN 20161213 AND 20161222
AND "DIM_4"."col4" > 0
I created a list with SQL, and then tried to apply regular expressions to extract the part of the where, but without success, it follows what I tried:
'for line in sql:'
'if re.search(r'[where]\W',line):'
'where.append(line)'
Unfortunately, I could not extract only the part of the where, can you tell me what error I made and how to fix it?