Thanks for the help and suggestions. I understand that Constraint
objects need to be bound to a Table to drop or create them. I thought
there might be a general, straightforward way to find a Constraint by
Table and name. I did find a such a way for Constraints defined on the
Table. The approach
The reason AddConstraint/DropConstraint need the Constraint attached to
the table is because ADD CONSTRAINT / DROP CONSTRAINT in SQL require the
table name, as these are related to ALTER TABLE . I
recommend you use Alembic ops to emit ADD CONSTRAINT / DROP CONSTRAINT
without requiring Table
Yes, the constraints are defined in Python and have names explicitly
defined. The CheckConstraint I need to use is defined in a @declared_attr
method for the column in a base class from which the mapped class inherits.
I did find the CheckConstraint I need in
Assuming here your constraints are already defined in Python and we are
not talking about using reflection, we're talking about the CHECK
constraint objects you've already built. If they are defined for a
Table then they would be in table.constraints. If you have them on the
Column then it's
I have a Declarative-instrumented class with several constraints, some
defined at the table level and some on a column. AFAICT, all the
constraints are configured correctly because they are rendered correctly by
CreateTable() when called with the class's Table instance. In order to
import some