Hi Gary,

thank you very much for your reply. I did as you suggested, and it worked.

I only wonder why those summeries are calculated, then. To no purpose? I 
don't know.

Karen

gjr80 schrieb am Donnerstag, 29. Oktober 2020 um 12:12:59 UTC+1:

> Hi,
>
> You are on the right track but making things difficult for yourself by 
> trying to use the daily summaries to obtain day max/min aggregates. Whilst 
> it’s true that the day max/min values can be found in the daily summaries 
> they are also available by querying the archive table. In this case 
> querying the archive will not take too long, if you were after max/min for 
> a month or year then you might consider going to the extra trouble of using 
> the daily summaries(or maybe not). The get_record() method has everything 
> there that you need to query the archive, have a look at the get_record() 
> method in weewx.restx.RESTThread 
> <https://github.com/weewx/weewx/blob/master/bin/weewx/restx.py#L261>, in 
> particular the part where dayRain is calculated 
> <https://github.com/weewx/weewx/blob/master/bin/weewx/restx.py#L322>. In 
> this case SUM() is used but it could just as easily be MAX() or MIN() to 
> give you the max/min for the day for the field you are interested in..
>
> Gary
>
> On Thursday, 29 October 2020 at 05:24:18 UTC+10 [email protected] wrote:
>
>> I searched the topics, and I did not found anything about that topic, so 
>> I try to ask.
>>
>> I am new to Weewx, and I am new to Python. So have mercy, if I do 
>> something stupid.
>>
>> I wanted to upload data to Wetternetz-Sachsen. There was no driver, so I 
>> tried to adapt an existing one. The example I used was the "Windy" driver. 
>> And I am glad to say it works. 
>>
>> All is fine so far.
>>
>> But they want the user to upload some aggregate values such as minimum 
>> temperature and maximum temperature, too. The record variable contains the 
>> data of the "archive" table, only. But there are additional tables such as 
>> "archive_day_outTemp". They are used in reports, but I found no way to 
>> access them.
>>
>> What did not work was that:
>>
>> def get_record(self, record, dbmanager): 
>>
>>     # run parent class 
>>     _datadict = super(WnsThread,self).get_record(record,dbmanager) 
>>     # actual time stamp 
>>     _time_ts = _datadict['dateTime'] 
>>
>>     try:
>>
>>         if 'outTempDayMax' not in _datadict:
>>
>>             _result = dbmanager.getSql(
>>                 "SELECT min,max FROM %s "
>>                 "WHERE dateTime = ?"
>>                 % "archive_day_outTemp", (_time_ts))
>>             if _result is not None:
>>                 _datadict['outTempDayMin']=_result[0]
>>                 _datadict['outTempDayMax']=_result[1]
>>     except weedb.OperationalError as e:
>>         log.debug("%s: Database OperationalError 
>> '%s'",self.protocol_name,e)
>>     return _datadict
>>
>> If I replace "archive_day_outTemp" by dbmanager.table_name, then no 
>> exception is raised any more, but the "archive" table is read instead of 
>> the table I want to read. So I see the problem is within the getSql() 
>> statement. But I have no clue.
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/f02e3289-3ed5-48e0-ab11-e2c0b4c59768n%40googlegroups.com.

Reply via email to