python - Django: store calculations results on database readings -


I am writing an app to control water consumption in various water meters. To simplify it, I can get a list of consumption readings in every meter every 15 minutes. I have a query that gives something like this:

  Date | Reading Point | Consumption ----------------- + -------------- + ------------ 03/05 / 2014 02:00 | 1 | 12/03/2014 02:00 | 2 | 12/03/2014 02:15 | 1 | 7/03/05 02:15 | 2 | 07/03/2014 02:30 | 1 | 11 03/05/2014 02:30 | 2 | 11 03/05/2014 02:45 | 1 | 23/03/2014 02:45 | 2 | 23 ....  

From time to time, I need some pre-calculations on these readings. Some examples:

  • Store the total consumption of each day
  • Store the maximum reading of each day
  • Store the monthly average consumption

This calculation is defined by the user, so I'm not sure how to model it. This pre-computed tables will be intensively inquired, so I think the ideal way to do this is to store each table in a separate table, but I'm not sure that Djangogo can produce such a dynamic model.

Here are my questions:

  • I'm sure there are tools to talk about this kind of thing, but before that I did not have to do this Do you want to avoid research or days of trial or week? Is there a "standard" way to achieve this behavior?

  • To start the process (SE) that does the pre-calculation, I'm thinking of using a slurry. Is this a right choice?

How is a general computing table?

  computation_id | Key | Price ----------------------- + ------------------------- - + --------- monthly_verage | "Read_points_id + month" | 1.2 weekly_maximum | "Reading_point_id + week" | 9 monthly_global_maximm | "Month". 12  

The key format will be defined along with user-defined computing. Computation_ID and identifier will be your mixed primary key. Computation_ID can be a numeric field (which will give you faster index lookup).

I doubt that despite a large desk the performance will be great.

I hope I do not misunderstand your requirements.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -