On Jun 6, 2014, at 3:56 PM, Leandro Poblet <[email protected]> wrote:
> Hello,
>
> I am using SQLAlchemy 0.9.4 and I'm having trouble passing this query +
> subquery to SQLAlchemy:
>
> SELECT id_tipo_espectaculo,nombre,descripcion FROM tipo_espectaculo
> WHERE (SELECT COUNT (*) FROM subtipo_espectaculo
> WHERE subtipo_espectaculo.id_tipo_espectaculo =
> tipo_espectaculo.id_tipo_espectaculo) > 0
>
> I've seen a few examples in Stack Overflow, but they have a completely
> different logic from what I'm doing, so I'm kind of lost.
the form of this, using assumed mappings, would be:
q1 =
sess.query(func.count('*')).select_from(SubtipoEspactaculo).filter(SubtipoEspactaculo.id_tipo_esp
= TipoEspectaculo.id_tip_es).correlate(TipoEscpectaculo).as_scalar()
q2 = sess.query(TipoEspectaculo).filter(q1 > 0)
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.