Re: [sqlalchemy] How to define a column property for whether model is the latest of a one-to-many relationship

2018-11-07 Thread phil . nachum
Seems to work great. Thanks so much! On Wednesday, November 7, 2018 at 11:33:11 AM UTC-8, Mike Bayer wrote: > > On Wed, Nov 7, 2018 at 1:05 PM > > wrote: > > > > I need help with structuring the query too. I can implement a query with > raw SQL, but it involves subqueries, and I'm not sure

Re: [sqlalchemy] How to define a column property for whether model is the latest of a one-to-many relationship

2018-11-07 Thread phil . nachum
I need help with structuring the query too. I can implement a query with raw SQL, but it involves subqueries, and I'm not sure how to translate it to a column property (or if there's a better way which would avoid the need for a subquery entirely) On Wednesday, November 7, 2018 at 9:54:15 AM

[sqlalchemy] How to define a column property for whether model is the latest of a one-to-many relationship

2018-11-07 Thread phil . nachum
I have the following two models class Dataset(db.Model): __tablename__ = 'datasets' id = db.Column(db.Integer, primary_key=True) creation_datetime = db.Column(db.DateTime(timezone=False), nullable= False) sample_id = db.Column(db.Integer, db.ForeignKey('samples.id'), nullable=

Re: [sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-27 Thread phil . nachum
Thanks for the detailed explanation. I'll try out some of those techniques. On Saturday, October 27, 2018 at 7:54:22 AM UTC-7, Mike Bayer wrote: > > On Fri, Oct 26, 2018 at 7:49 PM > > wrote: > > > > I see, thanks for the clarification about noload. > > > > Setting aside my specific issue,

Re: [sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-26 Thread phil . nachum
I see, thanks for the clarification about noload. Setting aside my specific issue, if using the session in before_insert/before_update events is not a good idea, what is generally the best way to perform validation across multiple models? Is it to just read the relationships from the model

Re: [sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-26 Thread phil . nachum
That didn't fix it. Why should noload not be used? We use it quite often to have more granular control over which tables get joined. Otherwise, some queries can become unnecessarily slow On Friday, October 26, 2018 at 11:45:29 AM UTC-7, Mike Bayer wrote: > > please remove those "noload"

[sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-26 Thread phil . nachum
I have the following three models (with other columns omitted): class ContainerSlot(db.Model): __tablename__ = 'container_slots' id = db.Column(db.Integer, primary_key=True) tube_id = db.Column(db.Integer, db.ForeignKey('tubes.id'), unique=True, index=True) container_id =

[sqlalchemy] Loading model in a text fixture causes load options to be ignored

2018-07-03 Thread phil . nachum
Hello, I'm encountering an issue where loading a model in a text fixture causes the load options to be ignored when I load the same model in a Flask endpoint I have these two models class Plate(db.Model): container_id = db.Column(db.Integer, db.ForeignKey('containers.id')) container

[sqlalchemy] Re: Debugging 'StatementError: Can't reconnect until invalid transaction is rolled back' error

2013-11-14 Thread Phil
To solve this problem, you should open a new db session at the beginning of the web request, and close the session at the end of the request. See the pattern here: http://docs.sqlalchemy.org/en/latest/orm/session.html#using-thread-local-scope-with-web-applications On Monday, October 31, 2011

[sqlalchemy] INNER JOIN inside an OUTER JOIN

2011-10-17 Thread Phil Vandry
to the SQL compiler has the joins defined flat, not hierarchically (i.e. the INNER JOIN of runways and airports is not an AST node under the RHS of the toplevel OUTER JOIN). Using SQLAlchemy 0.6.3 (from Debian stable... yeah, I know Debian is behind the current version) with MySQL 5.1.49. -Phil -- You

[sqlalchemy] Re: No attribute '_instance_key': Defining primary keys and surrogate primary keys

2008-01-29 Thread Phil Coombs
Works perfectly. Thanks again Michael. On 29 Jan, 20:13, Phil Coombs [EMAIL PROTECTED] wrote: Brilliant. Thanks for that lightning response, workaround and fix. I'll give the code a spin. On 28 Jan, 23:19, Michael Bayer [EMAIL PROTECTED] wrote: hi there - the bug is fixed in r4103

[sqlalchemy] Re: No attribute '_instance_key': Defining primary keys and surrogate primary keys

2008-01-29 Thread Phil Coombs
, at 4:03 PM, Phil Coombs wrote: Hi I'm a Python and SA newbie investigating SA for a project using Postgres. I have a database schema that I want to point SA at then be able to write my Python code. I'm working with a version of the basic_association example to keep things simple

[sqlalchemy] No attribute '_instance_key': Defining primary keys and surrogate primary keys

2008-01-28 Thread Phil Coombs
? Thanks in advance Phil Postgress DDL -- create table orders ( order_id Serial , o_customer_nametextnot null, o_order_date timestamp not null, primary key (o_customer_name, o_order_date) using index ,unique (order_id); create table