Jonathan LaCour wrote: > > Michael Hipp wrote: > >> And I have a record like this where the fields are populated and >> it has been saved in the database: >> >> full = MyThing(name="Foo", blah, blah) >> >> If I want to "empty" that record to convert it to look like: >> >> empty = MyThing() >> >> Where no fields are populated, can I just do something simplistic >> like this? [snip snip] Or is there some more elegant way to empty >> a record? > > I am not exactly sure why you would want to do this, and I > definitely don't understand your proposed solution. If a row is > empty (apart obviously from its primary key), you might as well just > delete it, no? > > Anyway, if you *do* decide that you really want to clear a row out > apart from its primary key, so that it shows up when you query for > results, but is basically empty, then you can iterate through the > non-primary-key columns, and set their value to None, which will > null out those values in the database. > > Again, I don't really see the point, but this is what you'd want to > do :)
Actually there are about 4 columns that I would preserve. They must remain because the row must still be there for the user to fill in. It's one of those things where you create a certain number of (almost) empty records and then the clerk fills them in. Deleting is not allowed as they represent a certain "place in line" to the thing in the record. And iterating thru all the umpteen other rows is the very thing I'm trying to avoid. Some of them won't readily hold None (e.g. Booleans). So I'm looking for a simple way to set a record back to it's default/empty state. (Excepting a few fields.) Is there no easy way to do this? Thanks, Michael --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SQLElixir" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlelixir?hl=en -~----------~----~----~----~------~----~------~--~---
