Database Problem

101 views
Skip to first unread message

Phil Owers

unread,
May 27, 2020, 7:06:30 PM5/27/20
to weewx-user
Have just tried to add avg_distance and lightning_strikes to the weewx.sdb. schema by adding
import schemas.wview
schema_extended = schemas.wview.schema + [('avg_distance', 'REAL'),('lightning_strikes', 'REAL')]
in the extension.py file
and in the weewx.conf
 changed schema = schemas.wview_extended.schema
 to schema = user.extensions.schema_extended
then
sudo ./bin/wee_database weewx.conf --reconfigure

The new weewx.sdb was produced and so I then did --rebuild-daily.
Restarted weewx and started getting a failure with $day.wind.max and also the following was produced in the log with 
May 27 19:20:11 raspberrypi weewx[529] INFO user.rtgd: rtgdthread: ****     data = self.calculate(cached_packet)
May 27 19:20:11 raspberrypi weewx[529] INFO user.rtgd: rtgdthread: ****   File "/home/weewx/bin/user/rtgd.py", line 1926, in calculate
May 27 19:20:11 raspberrypi weewx[529] INFO user.rtgd: rtgdthread: ****     wgust_tm_vt = ValueTuple(self.day_stats['wind'].max,
May 27 19:20:11 raspberrypi weewx[529] INFO user.rtgd: rtgdthread: **** KeyError: 'wind'

Had a look at the old and new weew.sdb and in the database file structure the tables had gone from 114 Table Schema in the original to 54 Table Schema after I had done the above change with daily_archive_wind missing with lots of others.
Reverted back to the original weewx.sdb and it was Ok again.
Im using weewx Ver 4.1
Just wondered if there was a different way of doing the above since version 4
Thanks for any help
Phil

vince

unread,
May 27, 2020, 8:00:10 PM5/27/20
to weewx-user
If you switch to the extended schema, you don't need to add the lightning elements a second time in weewx.conf, as they're already in the v4 extended schema, but you'd need to line up the names you picked so that they match the database schema.   The element names are "lightning_strike_count" and "lightning_distance" in the extended schema.  Look in bin/schemas for the schema definitions.

The procedure you followed looks right to me:
  • reconfigure so it uses the new database schema for the archive table
  • rebuild_daily to do the various summary tables.
The error you posted looks like you referred to a field in an extension (ie, 'wind') that isn't in the database schema.   Do you perhaps mean "windSpeed" in your user.rtgd file ?

Short answer is you probably want to do a little tweaking of your extension to use the built-in element names.   I think there was at least one post recently about how to clean up your archive tables if you need to rename something and want to save your old data, but it's probably worth the time longterm to do so and not need your customizations at all.

Wise choice keeping the old version to revert to :-)


Tom Keffer

unread,
May 27, 2020, 8:07:05 PM5/27/20
to weewx-user
There are now two ways of specifying a database schema. In the old way, the presence of 'wind' was detected by setting the database manager to WXDaySummaryManager. In the new way, it is explicitly mentioned in the schema. 

Unfortunately, you're mixing the two ways. 

If you wish to use the old way, make sure that option 'manager' is set to WXDaySummaryManager. So, your section [DataBindings] should read something like

[DataBindings]

    [[wx_binding]]
        # The database must match one of the sections in [Databases].
        # This is likely to be the only option you would want to change.
        database = archive_sqlite
        # The name of the table within the database
        table_name = archive
        # The manager handles aggregation of data for historical summaries
        manager = weewx.wxmanager.WXDaySummaryManager
        # The schema defines the structure of the database.
        # It is *only* used when the database is created.
        schema = user.extensions.schema_extended

Then try creating the new database.

An obscure error, I know!

-tk


--
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 weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/b4a60685-724e-4260-834e-3589af69dcba%40googlegroups.com.

Phil Owers

unread,
May 28, 2020, 4:03:27 AM5/28/20
to weewx-user
Sorry Im a little confused here.
If as an example you tried to add something new into weewx.sdb by using
import schemas.wview
schema_extended = schemas.wview.schema + [('whateveryoulikehere', 'REAL')]
in the extension.py file
with
 manager = weewx.manager.DaySummaryManager
I can see people falling into a bit of a black hole as looking back in the logs 
May 27 20:10:16 raspberrypi weewx[1464] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_Standard_NOAA_NOAA__Y_txt_tmpl.py", line 862, in respond
May 27 20:10:16 raspberrypi weewx[1464] ERROR weewx.cheetahgenerator: ****  NameMapper.NotFound: cannot find 'count' while searching for 'month.wind.count.raw'
and it didn't like  $day.wind.max from $day.wind.gustdir.ordinal_compass at $day.wind.maxtime  
So how can you add to weewx.sdb without it changing the structure and causing these errors 
Phil

Michi Kaa

unread,
May 28, 2020, 4:23:53 AM5/28/20
to weewx-user
Today I moved to user.extensions.schema_extended, but when i ran --rebuild-daily (or reconfigure, I really can't remember) I got an error that there is no "weewx.wxmanager.DaySummaryManager". I checked /usr/share/weewx/weewx/wxmanager.py and there is no such class. But there is "weewx.manager.DaySummaryManager" - so are the config examples with


# The manager handles aggregation of data for historical summaries
manager = weewx.wxmanager.DaySummaryManager

just typos?

John Kline

unread,
May 28, 2020, 9:09:03 AM5/28/20
to weewx...@googlegroups.com
You are missing the bin directory in the path you say you checked.

Would you check /usr/share/weewx/bin/weewx/wxmanager.py?


On May 28, 2020, at 1:23 AM, Michi Kaa <michael.k...@gmx.at> wrote:


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

Tom Keffer

unread,
May 28, 2020, 9:32:18 AM5/28/20
to weewx-user
Yes, unfortunately they are typos. They should read

manager = weewx.manager.DaySummaryManager.

Thanks for pointing this out!

-tk

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

Tom Keffer

unread,
May 28, 2020, 9:36:55 AM5/28/20
to weewx-user
Fixed in commit 6e84302. I also fixed the online version at weewx.com.

Michi Kaa

unread,
May 28, 2020, 9:43:17 AM5/28/20
to weewx-user
Also a big "thank you" for all the work and the support here.

I guess I don't have to ask myself anymore, if there is a difference between weewx.manager.DaySummaryManager and weewx.wxmanager.WXDaySummaryManager

Am Donnerstag, 28. Mai 2020 15:36:55 UTC+2 schrieb Tom Keffer:
Fixed in commit 6e84302. I also fixed the online version at weewx.com.

On Thu, May 28, 2020 at 6:31 AM Tom Keffer <tke...@gmail.com> wrote:
Yes, unfortunately they are typos. They should read

manager = weewx.manager.DaySummaryManager.

Thanks for pointing this out!

-tk

On Thu, May 28, 2020 at 1:23 AM Michi Kaa <michael....@gmx.at> wrote:
Today I moved to user.extensions.schema_extended, but when i ran --rebuild-daily (or reconfigure, I really can't remember) I got an error that there is no "weewx.wxmanager.DaySummaryManager". I checked /usr/share/weewx/weewx/wxmanager.py and there is no such class. But there is "weewx.manager.DaySummaryManager" - so are the config examples with


# The manager handles aggregation of data for historical summaries
manager = weewx.wxmanager.DaySummaryManager

just typos?

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