Pretty good, it worked fine!
Em quarta-feira, 13 de maio de 2015 12:49:43 UTC-3, willian coelho escreveu:
>
> Hello everyone,
>
> I`m getting an error when creating a new instance of my model `Type`. I
> have a many-to-many relationship between Type and Maker.
>
> Code:
>
> type_maker = db.Table(
> 'type_maker',
> db.metadata,
> db.Column('type_id', db.Integer, db.ForeignKey('type.id')),
> db.Column('maker_id', db.Integer, db.ForeignKey('maker.id')))
>
>
> class Type(db.Model):
> """VehicleType
> """
> __tablename__ = 'type'
> id = db.Column(db.Integer, primary_key=True)
> name = db.Column(db.String(50), unique=True, index=True)
> makers = db.relationship('Maker', secondary='type_maker', backref=db.
> backref('type'))
>
> def __repr__(self):
> return '<Type #{}: {}>'.format(self.id, self.name)
>
>
> class Maker(db.Model):
> """VehicleMaker
> """
> __tablename__ = 'maker'
> id = db.Column(db.Integer, primary_key=True)
> name = db.Column(db.String(50), index=True)
> versions = db.relationship('Version', backref=db.backref('maker'))
>
> def __repr__(self):
> return '<Maker #{}: {}>'.format(self.id, self.name)
>
>
> type_ = Type(name='Car')
>
>
>
> Error:
> 'tuple' object has no attribute 'foreign_keys'
>
> What is wrong with the code?
>
> Thanks in advance!
> Michael Coelho.
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.