Error in query many-to-many relationship in sqlalchemy using flask
<p>I have two models CoreDrive and GamificationTechnique and a generated table of a many-to-many relationship. I'm trying to do a simple query in table cores_techiques , but always get the error. </p>

<p>AttributeError: 'Table' object has no attribute 'query'. </p>

<p>I'm using python3, flask and sqlalchemy. I'm very beginner, I'm trying to learn flask with this application.</p>

<p>Models</p>

<pre><code>#many_CoreDrive_has_many_GamificationTechnique
cores_techiques = db.Table('cores_techiques',
db.Column('core_drive_id', db.Integer, db.ForeignKey('core_drive.id')),
db.Column('gamification_technique_id', db.Integer, db.ForeignKey('gamification_technique.id')))

class CoreDrive(db.Model):
id = db.Column(db.Integer(), primary_key=True)
name_core_drive = db.Column(db.String(80), unique=True)
description_core_drive = db.Column(db.String(255))
techniques = db.relationship('GamificationTechnique', secondary=cores_techiques,
   backref=db.backref('core_drives', lazy='dynamic'))

class GamificationTechnique(db.Model):
id = db.Column(db.Integer(), primary_key=True)
name_gamification_technique = db.Column(db.String(80), unique=True)
description_gamification_technique = db.Column(db.String(255))
number_gamification_technique = db.Column(db.Integer())
attributtes = db.relationship('Atributte', secondary=techniques_atributtes,
   backref=db.backref('gamification_techniques', lazy='dynamic'))
</code></pre>

<p>Routes</p>

<pre><code>@app.route('/profile')
def profile():
my_core_techique = cores_techiques.query.all()
my_user = User.query.first()
my_technique = GamificationTechnique.query.all()
return render_template('profile.html',my_user=my_user,my_technique=my_technique, my_core_techique=my_core_techique)
</code></pre>

<p>You can list all the <code>CoreDriver</code> and each object have a list of the <code>GamificationTechnique</code></p>

<pre><code>cores = CoreDrivers.query.all()
for core in cores:
    print core.techniques
</code></pre>

<p>With this in mind you can spend only the list <code>cores</code> to page</p>

python flask sqlalchemy flask-sqlalchemy