Phyton Unique constraint using data in multiple tables (SQL / SQLAlchemy) python unique constraint failed,python unique constraint,python sqlite unique

A top class called Parametric is used to create objects which 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 use SQLAlchemy for my ORM engine.

I want to impose a UNIQUE constraint that ensures that the combination (name, prop) are unique for a given class (e.g. only one instance of Foo can be called "my_foo" and have a prop value of, say "my_prop"), but I don't see how to reference the name column from Parametric in the Foo table UNIQUECONSTRAINT section.

Is this uniqueness something which can be imposed via FOREIGN KEY directives?

Answer:1



  1. python unique constraint failed
  2. python unique constraint
  3. python sqlite unique constraint failed
  4. python sqlite3 unique constraint failed
  5. python sqlalchemy unique constraint
  6. python sqlite unique constraint
  7. python integrityerror unique constraint failed
  8. python sqlite3 unique constraint

I'm looking for an equivalent to GetTickCount() on Linux. Presently I am using Python's time.time() which presumably calls through to gettimeofday(). My concern is that the time returned (the unix ...

I'm looking for an equivalent to GetTickCount() on Linux. Presently I am using Python's time.time() which presumably calls through to gettimeofday(). My concern is that the time returned (the unix ...

The following program loads two images with PyGame, converts them to Numpy arrays, and then performs some other Numpy operations (such as FFT) to emit a final result (of a few numbers). The inputs ...

The following program loads two images with PyGame, converts them to Numpy arrays, and then performs some other Numpy operations (such as FFT) to emit a final result (of a few numbers). The inputs ...