Tuesday, May 24, 2016

Re: get all columns as a list

Interesting. In all the cases I can think of, I would almost always want to keep the most recent check (not the oldest)... that tells me how recently the status of X was checked.  A more pedantic administrator might also want all those times stored, so a history can be created.

On Monday, 23 May 2016 18:22:06 UTC+2, Larry....@gmail.com wrote:
They're not identical - there's a timestamp - that is not one of the
columns compared.

The data is status data from a piece of equipment and we only want to
store changes. If 2 consecutive rows come in that are the same
(excluding the timestamp) I don't want to store the second one.

On Mon, May 23, 2016 at 12:14 PM, Derek <game...@gmail.com> wrote:
> OK - I don't really understand that; there should not be any 2 identical
> records in a database, but anyway, that was not the issue in this thread.
>
> On Monday, 23 May 2016 11:52:06 UTC+2, Larry....@gmail.com wrote:
>>
>> It's only 2 consecutive rows identical rows I need to exclude.
>>
>> On Mon, May 23, 2016 at 4:53 AM, Derek <game...@gmail.com> wrote:
>> > "When new data comes in I want to ... only add a new row if it differs."
>> >
>> > Pardon my curiosity, but isn't that the role of the set of unique keys
>> > for
>> > each record - to determine if it is "different"?
>> >
>> > On Friday, 20 May 2016 19:57:38 UTC+2, Larry....@gmail.com wrote:
>> >>
>> >> On Fri, May 20, 2016 at 2:26 AM, Gergely Polonkai <ger...@polonkai.eu>
>> >> wrote:
>> >> > Hello,
>> >> >
>> >> > Django can't do this out of the box, but see this post[1] for a
>> >> > possible
>> >> > solution with dicts.
>> >>
>> >> Well, it seems it can. As pointed out by Erik in another post, an
>> >> empty values_list() returns all the columns, which is what I want.
>> >>
>> >> > On the other hand, I started wondering why you need this, do you care
>> >> > to
>> >> > share the use case?
>> >>
>> >> When new data comes in I want to compare it to the most recently added
>> >> row and only add a new row if it differs.
>> >>
>> >>
>> >> > [1] http://stackoverflow.com/a/29088221/1305139
>> >> > [2] https://docs.djangoproject.com/en/1.9/topics/serialization/
>> >> >
>> >> > On May 20, 2016 00:13, "Larry Martell" <larry....@gmail.com> wrote:
>> >> >>
>> >> >> This is probably very simple, but I just can't figure out how to do
>> >> >> it.
>> >> >>
>> >> >> I want to get all the columns in some rows as a list. I know I could
>> >> >> use values_list and flat=True and list all the columns, but is that
>> >> >> the only way?
>> >> >>
>> >> >> I want to do something like this:
>> >> >>
>> >> >> rows = FOO.objects.filter(bar='baz')
>> >> >>
>> >> >> and get a list of lists instead a list of FOO objects.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f0022e10-6da3-4061-8348-0242f94c8ebc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment