Here's Postgresql's UPDATE syntax:
https://www.postgresql.org/docs/9.5/static/sql-update.html
as you can see the WHERE clause has only one option, so it's one row at
a time.
On 12/23/2016 03:11 PM, Brian Clark wrote:
Is there an update equivalent of this insert statement?
inserts = [{"name": "jon", "age": 20"}, {"name": "ashley", "age": 22"}]
session.execute(
People.__table__.insert().values(
inserts
)
)
I have this right now but it's still slower than I'd like because it's
using executemany, hoping to have it be one big query
updated_people = [{"b_id": 1, "b_name": "jon", "b_age": 21"}, {"b_id":
2, "b_name": "ashley", "b_age": 25"}]
stmt = People.__table__.update().\
where(People.id == bindparam('b_id')).\
values(name=bindparam('b_name'), age=bindparam('b_age'))
session.execute(stmt, updated_people)
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 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]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
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.