Thanks Mike,

at the end I resolved in this way:

async with engine.acquire() as conn:
            query = models.User.insert().values(email=email, first_name=
first_name, last_name=last_name, password=password).return_defaults()
            result = await conn.execute(query)
            user_id = await result.scalar()


Il giorno mercoledì 15 marzo 2017 14:37:29 UTC+1, Mike Bayer ha scritto:
>
> that's not SQLAlchemy, you're using this: 
>
> https://github.com/aio-libs/aiopg/blob/master/aiopg/sa/result.py#L205 
>
>
>
>
> On 03/15/2017 04:13 AM, Christian Barra wrote: 
> > Hello, 
> > 
> > I am trying to fetch the result of a query after an insert. 
> > 
> > SQLAlchemy 1.16 and PostgreSQL 9.6 
> > 
> > This is the code: 
> > 
> >         engine = self.request.app['db'] 
> >         async with engine.acquire() as conn: 
> >             query = models.User.insert().values(email=email, 
> first_name=first_name, last_name=last_name, 
> password=password).return_defaults() 
> >             result = await conn.execute(query) 
> > 
> >         id = result.returned_defaults['id'] 
> >         print(id) 
> > 
> > ad this is the error: 
> > 
> >     id = result.returned_defaults['id'] 
> > AttributeError: 'ResultProxy' object has no attribute 
> 'returned_defaults' 
> > 
> > The example from the docs is the 
> > same 
> http://docs.sqlalchemy.org/en/rel_1_1/core/dml.html#sqlalchemy.sql.expression.ValuesBase.return_defaults,
>  
>
> > apart from the async stuff 
> > 
> > -- 
> > 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 [email protected] <javascript:> 
> > <mailto:[email protected] <javascript:>>. 
> > To post to this group, send email to [email protected] 
> <javascript:> 
> > <mailto:[email protected] <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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to