python - Flask with SQLAlchemy tables doesn't link -


i have been struggling little sqlalchemy problem. tells me city.address referencing columns aren't associated foreignkeyconstraint.

here models

#address model class address(db.model):     id = db.column(db.integer, primary_key=true)     address = db.column(db.string(100), nullable=false)      company_id = db.column(db.integer, db.foreignkey('company.id'))     city_id = db.column(db.integer, db.foreignkey('city.id'), nullable=false)     event = db.relationship('address', backref='event', lazy='dynamic')     foreignkeyconstraint(['city_id'],['city.city_id'])      def __init__(self, address):         self.address = address      def __repr__(self):         return '<address %r>' % self.address  #city model class city(db.model):     id = db.column(db.integer, primary_key=true)     zip_code = db.column(db.string(10), unique=true)     city_name = db.column(db.string(100), unique=true)     country = db.column(db.string(100), unique=true)      address = db.relationship('city', backref='address', lazy='dynamic')     events = db.relationship('city', backref='event', lazy='dynamic')      primarykeyconstraint('id', 'city_id', name='city_pk')       def __init__(self, zipcode, cityname, country):         self.zip_code = zipcode         self.city_name = cityname         self.country = country      def __repr__(self):         return '<city %r>' % self.cityname 

i'm sure small thing problem hope getting set of eyes on help.

upfront thanks

check out sqlalchemy documentation : building relationship

i haven't tried flask should works using relationship.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -