how to transform this query to flask sqlalchemy object-oriented

Asked

Viewed 39 times

-3

I’ve been trying to do this for three days, I even managed to make it work directly in the database, but object-oriented in flask with sql Alchemy was not.

select cod_quest 
  from questoes a 
  where a.cod_quest not in (
     select cod_questao 
       from respostascurso b 
       where a.cod_quest is null = b.cod_questao 
    and b.grr="grr3123"
  ) 
  order by(a.num_quest);

It is a questionnaire, which the user answers it renders the next question at the time, so I need to check in the database which he has not yet answered, this query brings me this.

1 answer

0

solved, if anyone needs follow the answer.

db.session.query(Questoes.cod_quest). filter(~Questoes.cod_quest.in_(db.session.query(RespostasCurso.cod_questao).filter(Questoes.cod_quest.is_(None)==RespostasCurso.cod_questao, RespostasCurso.grr=="GR1234"))). all()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.