Hi, Currently I have a mapper like this: class Entity: def __init__(self, type, create, sentence_id, start, end): self.type = type self.create = create self.sentence_id = sentence_id self.start = start self.end = end
class Interval: def __init__(self, sentence_id, start, end): self.type = type self.create = create self.start = start self.end = end mapper(Interval, intervals_table) mapper(Entity, entities_table.join(intervals_table, intervals_table.c.interval_id == entities_table.c.interval_id)) However I have the problem that an interval is unique ( there is a UniqueConstraint("sentence_id", "start", "end") ). So when I create an Entity object like so e = Entity("FOO", "MADE BY BAR", 100, 2, 3 ) session.add(e) session.commit() then it works fine, now if I try to do this: e = Entity("SPAM", "MADE BY GUMP", 100, 2, 3) session.add(e) session.commit() then this will throw an IntegrityException. So I have tried using a transaction-esque way of doing this, first trying to select the interval_id from the intervals table and then setting e's interval_id. However this still doesnt work. Has anybody done anything like this before? Is there a simple way of doing this, maybe at the level of the mapper? Many thanks in advance, Nathan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---