sql - Django complex model - matching events with where clause -


in existing database have table tracking , correlating events , need ideas on how in django. intent query table sets of events occur @ same time. (this used things create scatter-plot graph 1 type of event on x-axis , type of event on y-axis each data point matched time occurred).

the db schema looks this.

table: event eventtime,        eventtype, eventvalue 2017-08-01 10:00, type1,     100 2017-08-01 11:00, type1,     200 2017-08-01 12:00, type1,     300 2017-08-01 10:00, type2,     10 2017-08-01 11:00, type2,     20 2017-08-01 12:00, type2,     30 2017-08-02 14:00, type3,     20 2017-08-02 16:00, type3,     30 

a sample query might (yes, ms-access - won't after porting django):

select      xaxis.eventtime xeventtime, xaxis.eventtype xeventtype, xaxis.value xvalue,       yaxis.eventtype yeventtype, yaxis.value yvalue,       event xaxis, event yaxis      xaxis.eventtime = yaxis.eventtime      , xaxis.eventtype='type1' , yaxis.eventtype='type2'      , xaxis.date_hour_utc > #2017-08-01 00:00# , xaxis.date_hour_utc < #2017-08-02 00:00# 

with result looking looking this:

xeventtime,       xeventtype, xvalue, yeventtype, yvalue 2017-08-01 10:00, type1,      100,    type2,      10 2017-08-01 11:00, type1,      200,    type2,      20 2017-08-01 12:00, type1,      300,    type2,      30 

any suggestions on how accomplish django models? or should run custom query pulls data? know rather complicated question assistance!


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -