F
Frank Millman
Hi all
I am trying to emulate a SQL check constraint in Python. Quoting from
the PostgreSQL docs, "A check constraint is the most generic constraint
type. It allows you to specify that the value in a certain column must
satisfy a Boolean (truth-value) expression."
The problem is that I want to store the constraint as a string, and I
was hoping to use ast.literal_eval to evaluate it, but it does not work.
ValueError: malformed node or string: <_ast.Compare object at ...>
Is there a safe way to do what I want? I am using python 3.3.
Thanks
Frank Millman
I am trying to emulate a SQL check constraint in Python. Quoting from
the PostgreSQL docs, "A check constraint is the most generic constraint
type. It allows you to specify that the value in a certain column must
satisfy a Boolean (truth-value) expression."
The problem is that I want to store the constraint as a string, and I
was hoping to use ast.literal_eval to evaluate it, but it does not work.
ValueError: malformed node or string: <_ast.Compare object at ...>
Is there a safe way to do what I want? I am using python 3.3.
Thanks
Frank Millman