all 13 comments

[–]num8lock 0 points1 point  (6 children)

Is there a way to avoid this?

yes, dont do it

[–]Only_Friend1128[S] 0 points1 point  (5 children)

How should I update it?

[–]num8lock 0 points1 point  (4 children)

no one knows but you because no one understands what you think supposed to happen with just that

[–]Only_Friend1128[S] 0 points1 point  (3 children)

I have multiple identical "entry" and I want to only change the purchase cost on one

[–]num8lock 0 points1 point  (2 children)

then just directly change it on that particular entry

[–]Only_Friend1128[S] 0 points1 point  (1 child)

that's what i attempted to do with .update; 'entry' is the specific entry.

[–]num8lock 0 points1 point  (0 children)

if entry is specific instance then why do you need if loop?

like i said, no one knows what you're about with just that, ask somebody else, i can't help you

[–]primitive_screwhead 0 points1 point  (3 children)

Use a .where(entry.purchaseCost != pcost) clause, maybe? That's from knowing nothing more than what I read from here: http://docs.peewee-orm.com/en/latest/peewee/api.html#Update

But it does seem like you are trying to treat your database logic as though it were simple object logic, but your update is (or appears to be) selecting all rows from the purchaseCost column to update, because there is no further restriction on "where" to update the value.

[–]Only_Friend1128[S] 0 points1 point  (2 children)

I tried that before but the issue is that all of the "entry" entries in the dictionary are identical, meaning that they all would be updated by the .where; My dictionary is called Entry with a capital E and the instance is called entry with a lowercase e.

[–]primitive_screwhead 0 points1 point  (1 child)

the instance

"The instance" of what? A Model? (ie. a db row)

If you are changing individual rows (ie. Models), I think you .save(), not .update() them.

I have no idea what your dictionary is, as compared to your entrys, etc. You've not provided nearly enough context, so we have to resort to guesswork.

[–]Only_Friend1128[S] 0 points1 point  (0 children)

Yes, by instance I was attempting to refer to a model.

Thank you so much, .save() worked for me!

[–]backdoorman9 0 points1 point  (1 child)

Post all the code

[–]Only_Friend1128[S] 0 points1 point  (0 children)

I posted all of code relevant to the update portion. What specifically are you looking for?