Ah, I didn't notice this part of your query:

.filter(..., Partsupp.ps_supplycost ==
session.query(func.min(Partsupp.ps_supplycost)))

I'm not sure exactly what SQL you are aiming for there, but I think
you need to add .correlate (or maybe .correlate_except) to that inner
query.

Simon


On Wed, Apr 18, 2018 at 5:24 PM, su-sa <sachdeva.sugandh...@gmail.com> wrote:
>
> Hi Simon,
>
> I am executing q2 on its own, may be I shouldnt have mentioned correlate,
> but if I dont mention it I get another error:
>
> sqlalchemy.exc.InvalidRequestError: Select statement 'SELECT
> min(partsupp.ps_supplycost) AS min_1
> FROM partsupp, part, supplier, nation, region
> WHERE part.p_partkey = partsupp.ps_partkey AND supplier.s_suppkey =
> partsupp.ps_suppkey AND supplier.s_nationkey = nation.n_nationkey AND
> nation.n_regionkey = region.r_regionkey AND region.r_name = ?' returned no
> FROM clauses due to auto-correlation; specify correlate(<tables>) to control
> correlation manually.
>
> I am not sure how I should go about it.
>
> Thanks for your help,
>
> Greetings,
> Sugandha
>
> On Wednesday, 18 April 2018 17:27:36 UTC+2, Simon King wrote:
>>
>> Are you executing q2 on it's own, or nested in a larger query? If so,
>> can you show the code for the larger query.
>>
>> I ask because you are calling ".correlate(Partsupp, Supplier, Nation,
>> Region)", which I think has the effect of removing those tables from
>> the FROM clause, in the assumption that they are part of the outer
>> query.
>>
>> Simon
>>
>>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> 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 sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to