Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off SQLAlchemy implicit_returning?

Trying to make insert query:

q_stat_insert = Stat.__table__.insert().values(insert_values)
res = Session.connection().execute(q_stat_insert, params)

but I have trigger on that table that returns NULL, how can I turn off RETURNING functionality?

Previously I've been avoiding this by simply using __table_args__ = ({'implicit_returning': False}) in my class declaration.

P.S. I'm using Postgresql 9.4 and SQLAlchemy 0.9.8

like image 742
Sleepwalker Avatar asked Sep 05 '26 13:09

Sleepwalker


1 Answers

INSERT statements have an inline parameter which, when set to True, stops the implicit returning for a given statement. Set this parameter inline = True within your insertion statement to turn off the implicit return. It's worth noting that the default parameter scheme for an insert statement looks like this, which is why you must set inline=True:

sqlalchemy.sql.expression.insert(table, values=None, inline=False,
  bind=None, prefixes=None, returning=None, return_defaults=False, **dialect_kw)

This is documented here for 0.9.

like image 167
miradulo Avatar answered Sep 08 '26 02:09

miradulo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!