Sorry, I don’t know why Google Groups decided to aggregate a few lines into 2 large lines. Here’s that list of versions again. Hopefully GG will be appeased this time.
--SQLAlchemy -The Python SQL Toolkit and Object Relational MapperTo 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+...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/1576c1a1-e108-4bb0-83eb-57ab4125c457n%40googlegroups.com.
That makes sense, but…. I’m afraid I don’t know how to add tb_br to the select.
I tried:
query = (
select(NV.id, func.min(bs_3.build_id))
.select_from(bs, Br)
…which gave:
…and I tried:
query = (
select(NV.id, func.min(bs_3.build_id), Br)
.select_from(bs)
.join(v_2, onclause=(bs.version_id == v_2.id))
.join(bs_2, onclause=(Br.id == bs_2.branch_id))
)
…which also gave:
(1054, "Unknown column 'tb_br.id' in 'on clause'")
I’m guessing I’m missing something simple, but I have no idea what.
Any (further) suggestions?
From:
sqlal...@googlegroups.com <sqlal...@googlegroups.com> on behalf of Mike Bayer <mike_not_...@zzzcomputing.com>
Date: Saturday, March 18, 2023 at 8:01 AM
To: noreply-spamdigest via sqlalchemy <sqlal...@googlegroups.com>
Subject: Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")
the query emitted is: SELECT tb_nv. id, min(bs_3. build_id) AS min_1 FROM tb_nv, tb_brst AS bs_3, tb_brst AS bs INNER JOIN tb_vers AS v_2 ON bs. version_id = v_2. id INNER JOIN tb_brst AS bs_2 ON tb_br. id = bs_2. branch_id the error means that your
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/1896c52f-a997-4bbc-b78f-47a13077e797%40app.fastmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/DM5PR12MB25034195B351C4A186BD7B99C5809%40DM5PR12MB2503.namprd12.prod.outlook.com.
I’m getting some pushback internally, from my team lead – he and I both think it’s probably too much detail to share. It’s 43 lines of SQL with multiple subqueries.
Would just the simplest parts of the from clause work?
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/282a420a-46a6-4fc0-96f2-d4ced697dc13%40app.fastmail.com.
Here’s the select, and most of the from clause:
select nv.id, min(bs.build_id) as min_build_id
from tb_v as v,
tb_nv as nv,
tb_bs as bs,
tb_br as br,
From:
'Dan Stromberg [External]' via sqlalchemy <sqlal...@googlegroups.com>
Date: Monday, March 20, 2023 at 2:16 PM
To: sqlal...@googlegroups.com <sqlal...@googlegroups.com>
Subject: Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")
I’m getting some pushback internally, from my team lead – he and I both think it’s probably too much detail to share. It’s 43 lines of SQL with multiple subqueries. Would just the simplest parts of the from clause work? From: sqlalchemy@ googlegroups. com
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/sqlalchemy/UDbK6bbDsDo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
sqlalchemy+...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/DM5PR12MB25037CCEB4E02BC36F40D831C5809%40DM5PR12MB2503.namprd12.prod.outlook.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/DM5PR12MB25037CCEB4E02BC36F40D831C5809%40DM5PR12MB2503.namprd12.prod.outlook.com.
Alright, using join_from may have led to clearing a hurdle. I’m now using:
query = (
select(NV.id, func.min(bs_3.build_id))
.select_from(bs)
.join(v_2, onclause=(bs.version_id == v_2.id))
.join_from(bs_2, Br, onclause=(Br.id == bs_2.branch_id))
)
..and am getting a new error:
sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1140, "In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'tact_dev.tb_nv.id'; this is incompatible with sql_mode=only_full_group_by")
Do I need to aggregate? Or perhaps change sql_mode?
Thanks!
From:
sqlal...@googlegroups.com <sqlal...@googlegroups.com> on behalf of Mike Bayer <mike_not_...@zzzcomputing.com>
Date: Monday, March 20, 2023 at 5:33 PM
To: noreply-spamdigest via sqlalchemy <sqlal...@googlegroups.com>
Subject: Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")
OK, not really, you want tables in the FROM clause. use either the select_from() or join_from() method to do that: https: //docs. sqlalchemy. org/en/20/tutorial/data_select. html#explicit-from-clauses-and-joins On Mon, Mar 20, 2023, at 5: 16 PM,
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/1550511f-e7b1-4160-99ef-8b63191a2ee2%40app.fastmail.com.
Hoping to save an iteration: the SQL currently looks like:
[SQL: SELECT tb_nv.id, min(bs_3.build_id) AS min_1
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/DM5PR12MB2503BC50CB1290BF9086D894C5819%40DM5PR12MB2503.namprd12.prod.outlook.com.
Granted, it’s difficult to read my (admittedly rather blank) mind. Maybe I should restate the question:
What are my options? I just want to see the rows from the query below. Why is it telling me I need to aggregate, and if I do truly need to, what might be an aggregate function that won’t eliminate much of what the query is producing?
From: 'Dan Stromberg [External]' via sqlalchemy <sqlal...@googlegroups.com>
Date: Tuesday, March 21, 2023 at 9:05 AM
To: sqlal...@googlegroups.com <sqlal...@googlegroups.com>
Subject: Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")
Alright, using join_from may have led to clearing a hurdle. I’m now using: query = ( select(NV. id, func. min(bs_3. build_id)) .select_from(bs) .join(v_2, onclause=(bs. version_id == v_2. id)) .join_from(bs_2, Br, onclause=(Br. id == bs_2. branch_id))
Alright, using join_from may have led to clearing a hurdle. I’m now using:
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/DM5PR12MB2503BC50CB1290BF9086D894C5819%40DM5PR12MB2503.namprd12.prod.outlook.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/DM5PR12MB2503EC98EAA7D442322B1E1FC5819%40DM5PR12MB2503.namprd12.prod.outlook.com.