是否可以检查查询删除了多少行?
queryset = MyModel.object.filter(foo=bar)
queryset.delete()
deleted = ...
或者我应该为此使用交易吗?
@transaction.commit_on_success
def delete_some_rows():
queryset = MyModel.object.filter(foo=bar)
deleted = queryset.count()
queryset.delete()
PHP + MySQL 示例:
mysql_query('DELETE FROM mytable WHERE id < 10');
printf("Records deleted: %d\n", mysql_affected_rows());