I'm working in Python. I have a set of rules that can be expressed as boolean operators (e.g. `operational_control == True && equity_share < 40`). The rules have some sort of notion of a priority, and they map to a set of constraints. Depending on the rule that matches a given object, I want to apply the constraints for that rule onto an SQL query. What's the optimal approach to implementing such a system?