I'm trying to analyze some SQL using python. I've got SQL that might contain multiple "on" clauses specifying table joins.
e.g
"on tableA.user_id = tableB.id"
I'd like to parse out all of the join relationships.
I tried the following but am having difficulty detecting multiple ones. It just finds the first one and stops there. Can someone help?
pattern = re.compile(r'on\s([^"\s]*)\s*=\s*([^"\s]*)')
results = re.search(pattern, sql)
for result in results.groups():
print result