CRITICAL __main__: Database OperationalError exception: (1054, "Unknown column 'rain' in 'field list'")

71 views
Skip to first unread message

Lucas Heijst

unread,
Mar 7, 2020, 9:53:34 AM3/7/20
to weewx-development
Tom,

The following three weewx programs got a critical error after startup of weewx version 4.0.0b14.

CRITICAL __main__: Database OperationalError exception: (1054, "Unknown column 'rain' in 'field list'")


weewx_klim formerly running version 4.0.0.a4
weewx_mben formerly running version 3.9.1
weewx_tfrc formerly running version 3.9.1

Note:
Program weewx_klim (klimalogg driver) does not have a rain database field
Program weewx_mben (modbus energy monitor) does not have a rain database field

All three programs use the same weewx_conf file with the old and with the new weewx version.

What can be done to debug this?

Note: the syslog says (see attachment):
INFO weewx.wxservices: The following values will be calculated: pressure=prefer_hardware, altimeter=prefer_hardware, appTemp=prefer_hardware, barometer=prefer_hardware, beaufort=prefer_hardware, cloudbase=prefer_hardware, dewpoint=prefer_hardware, ET=prefer_hardware, heatindex=prefer_hardware, humidex=prefer_hardware, inDewpoint=prefer_hardware, maxSolarRad=prefer_hardware, rainRate=prefer_hardware, windchill=prefer_hardware, windrun=prefer_hardware
while none of these values exist in the database. 

Snippet of weewx.conf:
=====
##############################################################################

#   This section can adjust data using calibration expressions.

[StdCalibrate]
    
    [[Corrections]]
        # For each type, an arbitrary calibration expression can be given.
        # It should be in the units defined in the StdConvert section.

##############################################################################

#   This section is for quality control checks. If units are not specified,
#   values must be in the units defined in the StdConvert section.

[StdQC]
    
    [[MinMax]]

##############################################################################

#   This section controls the origin of derived values.

[StdWXCalculate]
    [[Calculations]]
        # How to calculate derived quantities.  Possible values are:
        #  hardware        - use the value provided by hardware
        #  software        - use the value calculated by weewx
        #  prefer_hardware - use value provide by hardware if available,
        #                      otherwise use value calculated by weewx

##############################################################################
=====

Luc

syslog_20200307.txt

Thomas Keffer

unread,
Mar 7, 2020, 1:32:46 PM3/7/20
to Lucas Heijst, weewx-development
This is probably being caused by the "rainRate" calculator. The default is to calculate 'rainRate', despite you not having it listed in [[Calculations]]. 

What to do?
  1. We could remove rainRate from the defaults, and require it to be listed in [[Calculations]]. In fact, we could remove all defaults.
  2. Or, we could catch the exception and swallow it.
  3. Or, both.
I'm inclined to go with option #3.

-tk

 

--
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 weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/7a6ad431-8806-48f1-b471-c39411de62f4%40googlegroups.com.

mwall

unread,
Mar 7, 2020, 1:37:42 PM3/7/20
to weewx-development


On Saturday, March 7, 2020 at 1:32:46 PM UTC-5, Tom Keffer wrote:
This is probably being caused by the "rainRate" calculator. The default is to calculate 'rainRate', despite you not having it listed in [[Calculations]]. 

What to do?
  1. We could remove rainRate from the defaults, and require it to be listed in [[Calculations]]. In fact, we could remove all defaults.
  2. Or, we could catch the exception and swallow it.
  3. Or, both.
I'm inclined to go with option #3.

what provides the best out-of-box experience, i.e.,

1) rainRate just works without having to configure it
2) rain/rainRate failures do not happen if someone has a schema with no rain/rainRate in it 

this pattern probably applies to every other derived calculation as well...

(sorry i am not fully up to speed on all the changes to StdCalculate)

m

Thomas Keffer

unread,
Mar 7, 2020, 1:42:27 PM3/7/20
to mwall, weewx-development
That's where I'm heading.

rainRate calculations would continue to just happen because they are in the default weewx.conf that comes with WeeWX (and have been for a long time).

But, they shouldn't crash the system.

-tk

--
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 weewx-developm...@googlegroups.com.

Lucas Heijst

unread,
Mar 8, 2020, 1:58:32 PM3/8/20
to weewx-development
Tom,

This workaround in wxservices.py works for me.

    def _setup(self, stop_ts, db_manager):
        """Initialize the rain event list"""
        if self.rain_events is None:
            self.rain_events = []
        start_ts = stop_ts - self.retain_period
        try:
            # Get all rain events since the window start from the database
            for row in db_manager.genSql("SELECT dateTime, usUnits, rain FROM %s "
                                         "WHERE dateTime>? AND dateTime<=?;"
                                         % db_manager.table_name, (start_ts, stop_ts)):
                # Unpack the row:
                time_ts, unit_system, rain = row
                self.add_loop_packet({'dateTime': time_ts, 'usUnits': unit_system, 'rain': rain},
                                     db_manager)
        except weedb.DatabaseError as e:
            log.debug("DatabaseError '%s'" % e)

Thomas Keffer

unread,
Mar 15, 2020, 11:10:25 AM3/15/20
to Lucas Heijst, weewx-development
Fixed in commit b884c96

-tk

--
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 weewx-developm...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages