Hi group,

i build a model to save measurement data. a measurement entry has
always a channel (that is the source where the data comes from), a
value (for example 1.04), a unit (for example m/s or Hz) and a
timestamp.
The timestamp and the channel are together unique. every channel can
only have one data entry for one timestamp.

i have the following model:

class Data(models.Model):
    datetime = models.DateTimeField(help_text='the date and time of
the measurement value', db_index=True)
    channel = models.CharField(help_text='the channelname',
max_length=20, db_index=True)
    value = models.FloatField(help_text='the measurement value',
db_index=True)
    unit = models.CharField(help_text='the unit of the measurement
value', max_length=20, db_index=True)
    class Meta:
        unique_together = [('datetime', 'channel')]

now, i want to have a query to get the following data-table:

datetime                        channel1     unit1        channel2
unit2
2009-01-01 00:00:00       10.0            m/s         1000          Hz
2009-01-01 00:00:10       15.0            m/s         1040          Hz
2009-01-01 00:00:20       16.0            m/s         1563          Hz


Is something like this possible with django?
i know that i can get all data ordered by date and the use python to
get a datastructure like the described table. but i want to do it with
the database because i think it's much faster.

any ideas how to do this?


Best regards,

tom

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to