Re: get all columns as a list

2016-05-27 Thread Larry Martell
Just FYI, they did not want that change. They did not feel it added
any value. But in reality, they probably just didn't want me spending
time on it so I could do other things.

On Wed, May 25, 2016 at 9:35 AM, Larry Martell  wrote:
> I am the OP. I was implementing what my customer asked for. But you
> make a good point that they might want the latest data not the oldest.
> I will suggest that to them. Thanks.
>
> On Wed, May 25, 2016 at 9:29 AM, Derek  wrote:
>> We are both speaking as non-users of the OP's system. ;)
>>
>> I agree that there are some use cases for keeping the first measurement IF
>> the actual date of measurement makes no difference at all.  We have an app
>> like that, where we process real-time data and use a filter that only lets a
>> record through if there has been a "change since previous".  On the other
>> hand, changing the date means that the user has some reassurance that status
>> changes have been, and are, continuing to be made.  I think we saying the
>> same thing though: in general, in the absence of other constraints, try to
>> retain as much data as possible and archive it in preference to simply
>> tossing it.
>>
>> On Wednesday, 25 May 2016 00:52:01 UTC+2, James Schneider wrote:
>>>
>>>
>>> On May 24, 2016 9:11 AM, "Derek"  wrote:
>>> >
>>> > 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.
>>> >
>>>
>>> Not necessarily. You would want record of the initial change, not a record
>>> of the last time that value was seen. The assumption would be that the value
>>> remained constant until the next change event. What happens when the sensor
>>> goes offline and online, and then continues to report the same value on
>>> initialization? You wouldn't see anything until the sensor reported a
>>> changed value, which could be seconds, or years. That also means you've lost
>>> a data point that probably should have been captured.
>>>
>>> In doing so, you also potentially save a ton of write operations, since
>>> keeping the latest check would require extra logic to delete the old entry
>>> and create the new entry, or update the existing entry in place.
>>>
>>> The use case for the data would be the driver for what data needs to be
>>> retained. And also the use cases that haven't been thought of.
>>>
>>> I personally would prefer to keep all of the data points, and summarize
>>> the data in a report using logic similar to the OP's storage strategy.
>>> People tend to find interesting ways to use data, and you always end up with
>>> egg on your face if you are summarizing/tossing  the data on input rather
>>> than filtering/analyzing output.
>>>
>>> Obviously this is all barring other technical restrictions that may
>>> enforce a reduced data set.
>>>
>>> -James

-- 
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+unsubscr...@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/CACwCsY628aLDZuw1iDfNCERBWtMJM5CdbqqA%3De%2BdNDO7hNwjUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-25 Thread Larry Martell
I am the OP. I was implementing what my customer asked for. But you
make a good point that they might want the latest data not the oldest.
I will suggest that to them. Thanks.

On Wed, May 25, 2016 at 9:29 AM, Derek  wrote:
> We are both speaking as non-users of the OP's system. ;)
>
> I agree that there are some use cases for keeping the first measurement IF
> the actual date of measurement makes no difference at all.  We have an app
> like that, where we process real-time data and use a filter that only lets a
> record through if there has been a "change since previous".  On the other
> hand, changing the date means that the user has some reassurance that status
> changes have been, and are, continuing to be made.  I think we saying the
> same thing though: in general, in the absence of other constraints, try to
> retain as much data as possible and archive it in preference to simply
> tossing it.
>
> On Wednesday, 25 May 2016 00:52:01 UTC+2, James Schneider wrote:
>>
>>
>> On May 24, 2016 9:11 AM, "Derek"  wrote:
>> >
>> > 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.
>> >
>>
>> Not necessarily. You would want record of the initial change, not a record
>> of the last time that value was seen. The assumption would be that the value
>> remained constant until the next change event. What happens when the sensor
>> goes offline and online, and then continues to report the same value on
>> initialization? You wouldn't see anything until the sensor reported a
>> changed value, which could be seconds, or years. That also means you've lost
>> a data point that probably should have been captured.
>>
>> In doing so, you also potentially save a ton of write operations, since
>> keeping the latest check would require extra logic to delete the old entry
>> and create the new entry, or update the existing entry in place.
>>
>> The use case for the data would be the driver for what data needs to be
>> retained. And also the use cases that haven't been thought of.
>>
>> I personally would prefer to keep all of the data points, and summarize
>> the data in a report using logic similar to the OP's storage strategy.
>> People tend to find interesting ways to use data, and you always end up with
>> egg on your face if you are summarizing/tossing  the data on input rather
>> than filtering/analyzing output.
>>
>> Obviously this is all barring other technical restrictions that may
>> enforce a reduced data set.
>>
>> -James

-- 
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+unsubscr...@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/CACwCsY6RK1rSxAm_tai2ZJBm9uoxdJtA4_PcrRvhU_JkmVs9kw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-25 Thread Derek
We are both speaking as non-users of the OP's system. ;)

I agree that there are some use cases for keeping the first measurement IF 
the actual date of measurement makes no difference at all.  We have an app 
like that, where we process real-time data and use a filter that only lets 
a record through if there has been a "change since previous".  On the other 
hand, changing the date means that the user has some reassurance that 
status changes have been, and are, continuing to be made.  I think we 
saying the same thing though: in general, in the absence of other 
constraints, try to retain as much data as possible and archive it in 
preference to simply tossing it.

On Wednesday, 25 May 2016 00:52:01 UTC+2, James Schneider wrote:
>
>
> On May 24, 2016 9:11 AM, "Derek"  wrote:
> >
> > 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.
> >
>
> Not necessarily. You would want record of the initial change, not a record 
> of the last time that value was seen. The assumption would be that the 
> value remained constant until the next change event. What happens when the 
> sensor goes offline and online, and then continues to report the same value 
> on initialization? You wouldn't see anything until the sensor reported a 
> changed value, which could be seconds, or years. That also means you've 
> lost a data point that probably should have been captured.
>
> In doing so, you also potentially save a ton of write operations, since 
> keeping the latest check would require extra logic to delete the old entry 
> and create the new entry, or update the existing entry in place.
>
> The use case for the data would be the driver for what data needs to be 
> retained. And also the use cases that haven't been thought of.
>
> I personally would prefer to keep all of the data points, and summarize 
> the data in a report using logic similar to the OP's storage strategy. 
> People tend to find interesting ways to use data, and you always end up 
> with egg on your face if you are summarizing/tossing  the data on input 
> rather than filtering/analyzing output.
>
> Obviously this is all barring other technical restrictions that may 
> enforce a reduced data set.
>
> -James
>

-- 
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+unsubscr...@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/ac1260ee-c256-4ca0-8fe6-88fdca6141dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-24 Thread James Schneider
On May 24, 2016 9:11 AM, "Derek"  wrote:
>
> 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.
>

Not necessarily. You would want record of the initial change, not a record
of the last time that value was seen. The assumption would be that the
value remained constant until the next change event. What happens when the
sensor goes offline and online, and then continues to report the same value
on initialization? You wouldn't see anything until the sensor reported a
changed value, which could be seconds, or years. That also means you've
lost a data point that probably should have been captured.

In doing so, you also potentially save a ton of write operations, since
keeping the latest check would require extra logic to delete the old entry
and create the new entry, or update the existing entry in place.

The use case for the data would be the driver for what data needs to be
retained. And also the use cases that haven't been thought of.

I personally would prefer to keep all of the data points, and summarize the
data in a report using logic similar to the OP's storage strategy. People
tend to find interesting ways to use data, and you always end up with egg
on your face if you are summarizing/tossing  the data on input rather than
filtering/analyzing output.

Obviously this is all barring other technical restrictions that may enforce
a reduced data set.

-James

-- 
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+unsubscr...@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/CA%2Be%2BciVZJ9Etz%3Dh_F1c9kxSwBug%2B%2BoZ_xAtU1FjRGZ2X8phRnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-24 Thread Derek
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  
> 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  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"  
> 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+unsubscr...@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.


Re: get all columns as a list

2016-05-23 Thread James Schneider
On Mon, May 23, 2016 at 9:20 AM, Larry Martell 
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.
>
>
If you can coerce your incoming data into a dict using the same structure
as your model, you can probably do something like this:

new_data = {'col1': data1, 'col2': data2}
latest_db_record =
FOO.objects.filter(bar='baz').order_by('-timestamp').values('col1',
'col2')[0]

if new_data != latest_db_record:
new_data['bar'] = 'baz'
FOO.objects.create(**new_data)

Salt to taste as necessary.

You might also be able to work with qs.last() or qs.latest(), but those
return the actual objects and you can't take advantage of qs.values()
splitting it into a dict for you.

A DB transaction may also be appropriate if you have a lot of data rapidly
coming in.

-James

-- 
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+unsubscr...@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/CA%2Be%2BciWkVCzxVCOUJrPFaPM8yEQZa1oJ_3OGZ5U2Y%2BhSRJt2LQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-23 Thread Ketan Bhatt
Can you not do something like

`qs.filter(...info that is coming in...).exists()` 
If ^ is True, then update it, otherwise create a new object? 

-- 
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+unsubscr...@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/d9ffaeb7-f796-4d74-8ab3-1ee0cf1f5ca6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-23 Thread Larry Martell
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  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  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 
>> >> 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"  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+unsubscr...@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/CACwCsY4YoMkO8frUO3CZwVxbv6E3HS9UEiC8j9t64sd0k4Z2zg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-23 Thread Derek
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  
> 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  
> >> 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"  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...@googlegroups.com . 
> > To post to this group, send email to django...@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/e4a06bdf-c9df-46a7-9848-86238ddbf7cd%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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+unsubscr...@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/107edd46-8ca4-4856-bd34-558de2b940e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-23 Thread Larry Martell
It's only 2 consecutive rows identical rows I need to exclude.

On Mon, May 23, 2016 at 4:53 AM, Derek  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 
>> 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"  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+unsubscr...@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/e4a06bdf-c9df-46a7-9848-86238ddbf7cd%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@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/CACwCsY7%3D8tv4kDf2SDRqRsvMvg8dTb3HtqPRo5O8nkdvNHnmJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-23 Thread Derek
*"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  > 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"  > 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+unsubscr...@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/e4a06bdf-c9df-46a7-9848-86238ddbf7cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-20 Thread Larry Martell
On Fri, May 20, 2016 at 2:26 AM, Gergely Polonkai  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"  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+unsubscr...@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/CACwCsY4KpA8GDn5w-fXtKBooNzC5cNV16-USjGWGUUPvEF4eTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-20 Thread Larry Martell
On Fri, May 20, 2016 at 2:23 AM, Erik Cederstrand
 wrote:
>
>> Den 20. maj 2016 kl. 00.12 skrev Larry Martell :
>>
>> 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.
>
> "MyModel.objects.filter().values_list()" returns a list of tuples with all 
> column values in MyModel._meta.fields order. Does that not suffice?

Yes, that will work perfectly for me. I didn't know that about an
empty values_list returning all the columns. Thanks so much!

-- 
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+unsubscr...@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/CACwCsY6jcOtJ4YRHbWKWhpRSaaUEcOdkjxhGf3AR4x0mOWmwNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-20 Thread Gergely Polonkai
Hello,

Django can’t do this out of the box, but see this post[1] for a possible
solution with dicts.

You might also want to look at serialization[2]; it might help you a bit,
but again, it’s primarily for dicts, not lists.

On the other hand, I started wondering why you need this, do you care to
share the use case?

Cheers,
Gergely

[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"  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+unsubscr...@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/CACwCsY7EZtbmLqLgggZnnBspKbvOucPDki1i28zD3jtjGp%3DWFQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@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/CACczBUJBs87C9ayBxEyfWo4AX%2BFrB0Do%2BrNeNTtX7OKQyoxr%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-20 Thread Erik Cederstrand

> Den 20. maj 2016 kl. 00.12 skrev Larry Martell :
> 
> 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.

"MyModel.objects.filter().values_list()" returns a list of tuples with all 
column values in MyModel._meta.fields order. Does that not suffice?

Erik

-- 
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+unsubscr...@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/DCCE3570-B1B7-4E44-A0B6-1CB0FE8A24BF%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.