Код: Выделить всё
class Fruit(ModelBase):
__tablename__ = "fruits"
id = Column(BigInteger, nullable=False)
name = Column(Unicode)
price = Column(Integer)
Код: Выделить всё
+----+--------+-------+
| id | name | price |
+----+--------+-------+
| 1 | apple | 100 |
| 2 | carrot | 200 |
| 3 | orange | 300 |
+----+--------+-------+
Код: Выделить всё
+----+--------+-------+
| id | name | price |
+----+--------+-------+
| 1 | apple | 500 |
| 2 | carrot | 200 |
| 3 | orange | 600 |
+----+--------+-------+
Код: Выделить всё
updated_data = [{"id": 1, "name": "apple", "price": 500}, {"id": 3, "name": "orange", "price": 600}]
Я пробовал
Код: Выделить всё
update(Fruit).where(Fruit.id == updated_data.id).values(updated_data)
Подробнее здесь: https://stackoverflow.com/questions/703 ... el-at-once
Мобильная версия