Re: [sqlalchemy] Does SQLAlchemy support embedded class mapping?

2017-02-02 Thread cyril . bouteille
Great! Thanks! -- 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

Re: [sqlalchemy] Does SQLAlchemy support embedded class mapping?

2017-02-02 Thread mike bayer
On 02/02/2017 05:35 PM, cyril.boutei...@clearlabs.com wrote: Many Java ORMs support embedded class mappings, i.e. a relationship to a SCO which does not have a life of its own and is embedded in the table of the parent class, but I cannot find how to do this with SQLAlchemy. E.g. Human has a

[sqlalchemy] Does SQLAlchemy support embedded class mapping?

2017-02-02 Thread cyril . bouteille
Many Java ORMs support embedded class mappings, i.e. a relationship to a SCO which does not have a life of its own and is embedded in the table of the parent class, but I cannot find how to do this with SQLAlchemy. E.g. Human has a Head and the Head attributes get mapped inline in the Human

Re: [sqlalchemy] Session.enable_relationship_loading with inline select statement

2017-02-02 Thread mike bayer
On 02/02/2017 10:29 AM, Shane Carey wrote: Okay, perhaps there is another approach? I got my required behavior with something like t = Stuff(**kwargs) t = session.merge(t) print(t.dict()) session.rollback() But this causes the db to give t a primary key even though all I would like is the

Re: [sqlalchemy] Session.enable_relationship_loading with inline select statement

2017-02-02 Thread Shane Carey
Okay, perhaps there is another approach? I got my required behavior with something like t = Stuff(**kwargs) t = session.merge(t) print(t.dict()) session.rollback() But this causes the db to give t a primary key even though all I would like is the associated persistent objects. Unless I can

Re: [sqlalchemy] Session.enable_relationship_loading with inline select statement

2017-02-02 Thread mike bayer
On 02/02/2017 09:29 AM, Shane Carey wrote: Hi, I have a use case where I need to enable relationship loading on a single object. However, I initialize the foreign key of this relationship using an inline select statement. @event.listens_for(Thing, 'init', propagate=True) def

[sqlalchemy] Session.enable_relationship_loading with inline select statement

2017-02-02 Thread Shane Carey
Hi, I have a use case where I need to enable relationship loading on a single object. However, I initialize the foreign key of this relationship using an inline select statement. from sqlalchemy import * from sqlalchemy import select, and_, event, inspect from sqlalchemy.orm import * from