Re: [sqlalchemy] Getting a triple of related id fields

2023-06-21 Thread Dan Stromberg
On Tue, Jun 20, 2023 at 3:47 PM Mike Bayer wrote: > > > step 1 is stop using that silly Flask extension that gives you > "Pipeline.query", I can't tell what it is you want to SELECT from either by > reading this query. Wow, that made things a lot easier. Is there any reason to avoid mixing

[sqlalchemy] Getting a triple of related id fields

2023-06-20 Thread Dan Stromberg
I've been banging on this for hours, but I seem to be getting nowhere. I've tried more things that I can count, but here are two of my attempts: # result = ( #Pipeline.query # .select_from(Storage, NewProduct) # .join(Storage, pipeline_alias1.storage_id == Storage.id) #

[sqlalchemy] Turning a complex query into a view for SQLAlchemy?

2023-06-16 Thread Dan Stromberg
Hi. In https://pajhome.org.uk/blog/10_reasons_to_love_sqlalchemy.html it says: When performing highly complex queries, it is possible to define these with SQLAlchemy syntax. However, I find there's a certain level of complexity where it becomes easier to write SQL directly. In that case, you can

[sqlalchemy] subquery relationships?

2023-05-31 Thread Dan Stromberg
Hi folks. I have a subquery that is selected from a table with 5 foreign keys, and joined with another table with 3 foreign keys. And then that subquery is used in a join with the table having the 3 foreign keys again. I don't know how to tell what column(s) that join is happening on. What

[sqlalchemy] Interpreting a SA traceback

2023-05-24 Thread Dan Stromberg
I know, python2 is long dead. We’re almost ready for Python3, but not quite. Anyway, here’s a traceback that I’m not sure what to make of. Is it saying that a transaction got so big that it couldn’t be fully flushed within the timeout window? I’ve elided a sensitive part from the very end of

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-21 Thread 'Dan Stromberg [External]' via sqlalchemy
eliminate much of what the query is producing? From: 'Dan Stromberg [External]' via sqlalchemy Date: Tuesday, March 21, 2023 at 9:05 AM To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-21 Thread 'Dan Stromberg [External]' via sqlalchemy
Hoping to save an iteration: the SQL currently looks like: [SQL: 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, tb_brst AS bs_2 INNER JOIN tb_br ON tb_br.id = bs_2.branch_id] From: 'Dan Stromberg

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-21 Thread 'Dan Stromberg [External]' via sqlalchemy
torial/data_select.html*explicit-from-clauses-and-joins__;Iw!!Ci6f514n9QsL8ck!gsSZYRslnIShc80D5SJP9hQv7FJkNL5Bzfvc8dkqobmEg8-ctkAcRyR1sZuv3pRL4eCzLvlJC-VDSf5sXXQNtX0d4POMpzTQh3-QUw$> On Mon, Mar 20, 2023, at 5:16 PM, 'Dan Stromberg [External]' via sqlalchemy wrote: I’m getting some pushback int

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-20 Thread 'Dan Stromberg [External]' via sqlalchemy
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 Date: Monday, March 20, 2023 at 2:16 PM To: sqlalchemy@googlegroups.com Subject: Re

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-20 Thread 'Dan Stromberg [External]' via sqlalchemy
n Mon, Mar 20, 2023, at 10: 33 AM, 'Dan Stromberg [External]' via sqlalchemy wrote: 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, what SQL are you going for ? start with that. On Mon, Mar 20, 2023, at 10:33 AM, 'Dan Stromberg

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-20 Thread 'Dan Stromberg [External]' via sqlalchemy
query to include some indication how tb_br is part of what's being joined. On Fri, Mar 17, 2023, at 7:52 PM, 'Dan Stromberg' via sqlalchemy wrote: Hi people. I'm having trouble with a test query. As the subject line says, I'm getting: sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-17 Thread 'Dan Stromberg [External]' via sqlalchemy
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. I'm using: $ python3 -m pip list -v | grep -i sqlalchemy Flask-SQLAlchemy 2.5.1

[sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-17 Thread 'Dan Stromberg' via sqlalchemy
Hi people. I'm having trouble with a test query. As the subject line says, I'm getting: sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'") But it seems like tb_br exists, and has an id column - tb_br being an empty table, but still,