У меня есть набор таблиц: спортсмены, оценки, категории, rel_ath_grad_cath.
< div class="s-table-container">
спортсмены
оценки
категории
rel_ath_grad_cath
< tr>
id_ath
id_grad
id_cat
id_ath
name_ath
name_grad
name_cat
id_grad
id_cat
Мне нужны мои показы в виде дерева | идентификатор_ath | имя_путь | имя_град | name_cat |
Когда я работаю за одним столом, драмы нет
Код: Выделить всё
def afficher_donnees():
my_conn.execute('SELECT * FROM `athletes`')
rqsa_aths = my_conn.fetchall()
for ath in rqsa_aths:
trv.insert('', 'end', values=(ath[0], ath['1'], ath[2]))
Но когда я хочу взять все остальное, есть кошмар
Код, который я пробовал:
Код: Выделить всё
def afficher_donnees():
# Select all athletes
my_conn.execute('SELECT * FROM `athletes`')
rqsa_aths = my_conn.fetchall()
# nb_athl
nb_athl = len(rqsa_aths)
i = 0
data_agt = []
# I want to take the grad corresponding to the ath
for ath in rqsa_aths:
while nb_athl+1 > i:
# For the i ath i take the id
id_ath = ath[i]
name = ath[1]
# Then take the grad wich corresponding to the id
my_conn.execute('SELECT `name_grad` FROM `grades`
JOIN rel_ath_grad_cath RAGC
ON RAGC.id_grad = grades.id_grad
JOIN athletes ATH
ON RAGC.id_ath = ATH.id_ath
WHERE ATH.id_ath = %s' %id_ath)
grad_ath = my_conn.fetchone()
trv.insert('', 'end', values=(ath[0], ath['1'], grad_ath[0]))
i = i+1
НИЧЕГО НЕ ПОЯВЛЯЕТСЯ
Кто-нибудь поможет мне понять, в чем дело?
Подробнее здесь: https://stackoverflow.com/questions/792 ... ql-queries