Reputation: 43
In MySQL it is possible to limit the number of records affected by an update query. In an ideal world this should not be necessary, but having such a limit does in some cases help save your bacon :)
I'd have thought that in SQLAlchemy it can be achieved by something like:
tgt_meta.tables['ps_product'].update(tgt_meta.tables['ps_product'].c.id_product == product_id).values(**upd_product_values).limit(1)
But apparently this is not so.
AttributeError: 'Update' object has no attribute 'limit'
Is there something else that I can try?
Upvotes: 3
Views: 1283
Reputation: 75217
The Mysql dialect has this thrown in as update(..., mysql_limit=x)
https://docs.sqlalchemy.org/en/latest/dialects/mysql.html#mysql-sql-extensions
Upvotes: 4