On 01/18/2012 02:14 PM, Martijn Moeling wrote:
> I managed to get PG (9.0) installed and I am in the process over
> moving over from MySQL,
> I allready have stuff working and am now trying to get the main reason
> for the Quick move: Sequence.
>
> I have a object like:
>
> seq=Sequence('serialnumber', metadata=Base.metadata)
> Class Object1(Base):
> Id= Column(Integer, primary_key=True)
> SerialNumber= Column(Integer, seq) # Or whatever I try here
>
>
> Class Object(Base):
> Id= Column(Integer, primary_key=True)
> SerialNumber= Column(Integer, ForeignKey('object1.SerialNumber')
>
>
> with a create_all I get this:
> (ProgrammingError) there is no unique constraint matching given keys
> for referenced table "object1"
>
> I might be looking in the wrong direction here, the documentation only
> talks about Sequence with primary_key set to True
>
> MartijnPostgreSQL requires the target of a foreign key (Object1.SerialNumber in your case) to have a unique constraint on it. Adding "unique=True" to the column definition would do it. -Conor -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
