170 похожих чатов

Почему в results пусто? есть идеи? https://pastebin.com/4vahZibK то есть Country убираем и

все нормально идет
results = db_session.query(Game, Competition, Stage).filter(
((Game.home_name == 'Барселона') | (Game.guest_name == 'Барселона'))
).join(Competition).join(Stage).order_by(Game.date.desc())


for stats_game, competition, stage in results:
print(f'stats_game, competition, stage: {stats_game} {competition} {stage}')
stats_game, competition, stage: <models.Game object at 0x7f363679a5d0> <models.Competition object at 0x7f3636a70150> <models.Stage object at 0x7f363756fc90>

12 ответов

5 просмотров
Stanislav- Автор вопроса

то есть Country убираем и все нормально идет results = db_session.query(Game, Competition, Stage).filter( ((Game.home_name == 'Барселона') | (Game.guest_name == 'Барселона')) ).join(Competition).join(Stage).order_by(Game.date.desc()) for stats_game, competition, stage in results: print(f'stats_game, competition, stage: {stats_game} {competition} {stage}') stats_game, competition, stage: <models.Game object at 0x7f363679a5d0> <models.Competition object at 0x7f3636a70150> <models.Stage object at 0x7f363756fc90>

Stanislav- Автор вопроса

results = db_session.query(Game, Competition, Stage, Country).join(Competition).join(Country).join(Stage).order_by(Game.date.desc()) for stats_game, competition, stage in results: print(f'stats_game, competition, stage: {stats_game} {competition} {stage}') пусто. то есть что-то не хочет работать join для Country. вопрос почему? может в models.py накосячил?

Stanislav- Автор вопроса
Tishka17
Запрос смотрел?

я же отправил запрос на пастбине 2023-05-20 01:48:43,934 INFO sqlalchemy.engine.Engine SELECT games.id AS games_id, games.game_id AS games_game_id, games.date AS games_date, games.competition_id AS games_competition_id, games.stage_id AS games_stage_id, games.home_name AS games_home_name, games.guest_name AS games_guest_name, games.home_score AS games_home_score, games.guest_score AS games_guest_score, games.competition AS games_competition, games.country_id AS games_country_id, competitions.id AS competitions_id, competitions.name AS competitions_name, competitions.show AS competitions_show, stages.id AS stages_id, stages.name AS stages_name, countries.id AS countries_id, countries.name AS countries_name FROM games JOIN competitions ON competitions.id = games.competition_id JOIN stages ON stages.id = games.stage_id JOIN countries ON countries.id = games.country_id 2023-05-20 01:48:43,935 INFO sqlalchemy.engine.Engine [cached since 143.2s ago] ()

Stanislav
я же отправил запрос на пастбине 2023-05-20 01:48...

Так может просто нет таких данных, чтобы сразу в 4 таблицах все было?

Stanislav- Автор вопроса
Stanislav
данные точно есть сразу в 4 таблицах

На всякий случай: ты знаешь разницу inner и outer join?

Stanislav- Автор вопроса

main1.py - без Country main2.py c Country #main1.py from models import Game, Stage, Competition, Country, db_session results = db_session.query(Game, Competition, Stage).join(Competition).join(Stage) for stats_game, competition, stage in results: print(f'stats_game, competition, stage: {stats_game} {competition} {stage}') stats_game, competition, stage: <models.Game object at 0x7f70ed237250> <models.Competition object at 0x7f70ee907d90> <models.Stage object at 0x7f70ed376510> stats_game, competition, stage: <models.Game object at 0x7f70ed2373d0> <models.Competition object at 0x7f70ee50ff90> <models.Stage object at 0x7f70eeb9b810> stats_game, competition, stage: <models.Game object at 0x7f70eca1a410> <models.Competition object at 0x7f70ee50ff90> <models.Stage object at 0x7f70eeb9b810> #main2.py from models import Game, Stage, Competition, Country, db_session results = db_session.query(Game, Competition, Stage, Country) for stats_game, competition, stage in results: print(f'stats_game, competition, stage, country: {stats_game} {competition} {stage} {country}') 2023-05-20 20:28:22,823 INFO sqlalchemy.engine.Engine SELECT games.id AS games_id, games.game_id AS games_game_id, games.date AS games_date, games.competition_id AS games_competition_id, games.stage_id AS games_stage_id, games.home_name AS games_home_name, games.guest_name AS games_guest_name, games.home_score AS games_home_score, games.guest_score AS games_guest_score, games.competition AS games_competition, games.country_id AS games_country_id, competitions.id AS competitions_id, competitions.name AS competitions_name, competitions.show AS competitions_show, stages.id AS stages_id, stages.name AS stages_name, countries.id AS countries_id, countries.name AS countries_name FROM games, competitions, stages, countries 2023-05-20 20:28:22,823 INFO sqlalchemy.engine.Engine [generated in 0.00048s] () ```

Stanislav
main1.py - без Country main2.py c Country #main1.p...

Три вижу, а четвертая? Страна вообще указана?

Stanislav
main1.py - без Country main2.py c Country #main1.p...

Вот в первом запросе ты вывел какие-то Game. Что там указано в качестве страны?

Похожие вопросы

Обсуждают сегодня

я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
Всем привет! Массив вводится с клавиатуры, кол-во элементов неизвестно, поэтому я указал arr db 100 dup(?) С нахождением максимума проблем нет, а вот минимум почему-то всегд...
En Vind Av Sorg
11
в сях есть множество как в питоне? для удаление дубликатов
Linus
25
читать файл максимально быстро? странный вопрос))
zamtmn
53
Кто создает тут ботов для телеграмм групп ?
Antskup
8
а как бы вылезти из ИО, что то типа IO -> Ether или в какую сторону смотреть ? что то туплю
Fedor
14
Вроде бы вопрос уже заезжанный, но тем не менее У меня есть функция menu() которая выводит набор возможных действий, а затем спрашивает у пользователя что он хотел бы сделать....
David Golovatin
2
Я хочу запустить свой проект в тг. Что-то между пирамидой и майнилкой. Еще подобного ничего не было. Уникальная идея. Нужен именно не бот, а приложение. С ввод, выводом тон...
Павел А.
6
а зачем этот вопрос для удаления из чата?
Mёdkinson Medvezhkin
63
тоесть, указав return eax, сгенерируется никому ненужная инструкция mov eax,eax ?
Aiwan \ (•◡•) / _bot
24
Карта сайта