A top class named Parametric used to create objects that can have parameters associated with them:
class Parametric(object): def __init__(self, name): self.name = name self.pars = [] class Foo(Parametric): def __init__(self, name, prop): self.prop = prop Parametric.__init__(self, name) class Bar(Parametric): def __init__(self, name, prop): self.prop = prop Parametric.__init__(self, name)
I am using SQLAlchemy for my ORM mechanism.
I want to impose a UNIQUE constraint that ensures that the combination ( name , prop ) is unique to this class (for example, only one instance of Foo can be called "my_foo" and have a prop value, say "my_prop" ), but I donβt see how to refer to the name column of Parametric in the Foo table UNIQUECONSTRAINT .
Is this uniqueness something that can be applied using FOREIGN KEY directives?
python sql sqlalchemy unique-constraint
Escualo
source share