2

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?

wshyang
  • 33
  • 6

1 Answers1

3

The Mysql dialect has this thrown in as update(..., mysql_limit=x)

https://docs.sqlalchemy.org/en/latest/dialects/mysql.html#mysql-sql-extensions

Ilja Everilä
  • 50,538
  • 7
  • 126
  • 127
zzzeek
  • 72,307
  • 23
  • 193
  • 185