I think you will find the issue is that interval is a reserved word in 
MySQL. The solution is to enclose interval in backticks, eg: 'interval'

Gary

On Thursday, 11 March 2021 at 18:54:12 UTC+10 [email protected] wrote:

> You are using MySQL or MariaDB? I use Sqlite. There this statemant works. 
>
> I am not really at home with MySQL, but could you change the statement 
> like that:
>
>           _result = db_manager.getSql(
>                     "SELECT SUM(radiation*interval/60.0), "
>
>                     "MIN(usUnits), MAX(usUnits) FROM %s "
>                     "WHERE dateTime >? AND dateTime<=?"
>                     % db_manager.table_name, timespan)
>
> issue #5 <https://github.com/roe-dl/weewx-GTS/issues/5>
>
> If that does not help I would move the division by 60 from the SQL 
> statement to the Python code. But first I ask you to check if that change 
> works.
>
> [email protected] schrieb am Donnerstag, 11. März 2021 um 09:23:39 UTC+1:
>
>> in line 546 
>> def calc_radiation_integral(self, timespan, db_manager):
>>         """calculate radiation integral over time
>>
>>         radiation: actual radiation in Watt per square meter
>>         interval:  registration interval as per database record in minutes
>>
>>         """
>>
>>         try:
>>             _result = db_manager.getSql(
>>                     "SELECT SUM(radiation*interval)/60.0, "
>>                     "MIN(usUnits), MAX(usUnits) FROM %s "
>>                     "WHERE dateTime >? AND dateTime<=?"
>>                     % db_manager.table_name, timespan)
>>
>> is there a sql error
>>
>> Mar 11 09:20:26 hesba weewx[16349] ERROR weewx.reportengine:         
>> ****    File "/home/weewx/bin/user/GTS.py", line 559, in 
>> calc_radiation_integral
>> Mar 11 09:20:26 hesba weewx[16349] ERROR weewx.reportengine:         
>> ****      % db_manager.table_name, timespan)
>> Mar 11 09:20:26 hesba weewx[16349] ERROR weewx.reportengine:         
>> ****    File "/home/weewx/bin/weewx/manager.py", line 430, in getSql
>> Mar 11 09:20:26 hesba weewx[16349] ERROR weewx.reportengine:         
>> ****      _cursor.execute(sql, sqlargs)
>> Mar 11 09:20:26 hesba weewx[16349] ERROR weewx.reportengine:         
>> ****    File "/home/weewx/bin/weedb/mysql.py", line 61, in guarded_fn
>> Mar 11 09:20:26 hesba weewx[16349] ERROR weewx.reportengine:         
>> ****      raise klass(e)
>> Mar 11 09:20:26 hesba weewx[16349] ERROR weewx.reportengine:         
>> ****  weedb.DatabaseError: (1064, "You have an error in your SQL syntax; 
>> check the manual that corresponds to your MariaDB server version for the 
>> right syntax to use near ')/60.0, MIN(usUnits),MAX(usUnits) FROM archive 
>> WHERE dateTime>1612825200 AND ...' at line 1")
>> Mar 11 09:20:26 hesba weewx[16349] ERROR weewx.reportengine:         
>> ****  Generator terminated
>>
>>
>> [email protected] schrieb am Mittwoch, 10. März 2021 um 20:39:50 UTC+1:
>>
>>> The radiation observation type provides the actual sun power received at 
>>> the time of measurement. The value depends on cloud coverage and the time 
>>> of day.
>>>
>>> Besides that it is interesting to know which amount of energy was 
>>> received from the sun during the day or any other period of time.
>>>
>>> To get that value some calculation has to be done. Unlike with rain that 
>>> cannot be done by simply summarizing the observation readings. Energy is no 
>>> cumulative value. Instead, it is necessary to integrate (in the 
>>> mathematical meaning of that word) the radiation readings over the 
>>> aggregation interval.
>>>
>>> I extended GTS extension <https://github.com/roe-dl/weewx-GTS> to do 
>>> that.
>>>
>>> For example you can display the amount of sun energy received the day 
>>> before by using the tag $yesterday.radiation.energy_integral. Plots are 
>>> also possible.
>>>
>>> For examples showing these values see:
>>> sun radiation energy value <https://www.woellsdorf-wetter.de>
>>> sun radiation energy plot 
>>> <https://www.woellsdorf-wetter.de/graphs/?graph=month#Sonnenenergie>
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" 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-user/d0999073-e878-47cc-b180-0cf823ba5ee6n%40googlegroups.com.

Reply via email to