Thanks, I am able to call my object, but the attribute prints none: 

E.g. my model is: 

class User(Dictifiable, db.Model, UserMixin):
    __tablename__ = 'user'

    id = Column(Integer, Sequence('user_id_seq'), primary_key=True)
    full_name = Column(String(50))


And this is what I have done : 

`u_lazy = User(id=1)`
`db.session().enable_relationship_loading(u_lazy)`
when i try to print u_lazy.full_name, it shows null (it is non null in db 
 ) 


On Friday, 2 March 2018 10:55:11 UTC-5, Mike Bayer wrote:
>
> On Fri, Mar 2, 2018 at 10:52 AM, Harshvardhan Gupta 
> <harsh...@gmail.com <javascript:>> wrote: 
> > Thanks for the reply. 
> > 
> > There is a guarantee that the user will exist ,why is why I want to 
> prevent that extra db query. 
> > 
> > When I try to do enable relationship loading ,I get the error : 
> > Scoped session has no attribute enable relationship loading. 
>
> that's a scoped_session(), not a Session, access the Session by 
> calling it:  scoped_session().enable_relationship_loading(obj) 
>
> > 
> > -- 
> > 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+...@googlegroups.com <javascript:>. 
> > To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:>. 
> > 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