An SQL constraint has a whole lot that Python can't do conveniently, and vice versa, so I think you do yourself a disservice by trying to tie yourself to that.
The problem here is that 'in' is an operator, so this is not a literal. One possible solution would be to separate out your operator (and have just a handful permitted), and then use ast.literal_eval for
just the second operand - something like this:
import ast
import operator
ops = {
'in':lambda x,y: x in y, # operator.contains has the args backwards
'==':operator.eq, # or use '=' for more SQL-like syntax
'':operator.gt,
}
op, value = 'in', "('abc', 'xyz')"
x = 'abc'
if ops[op](x,ast.literal_eval(value)):
print("Constraint passed")
else:
print("Ignore this one")