weectl database reconfigure

70 views
Skip to first unread message

Werner Krenn

unread,
Nov 3, 2025, 1:05:06 PM (2 days ago) Nov 3
to weewx-user
WeeWx 5.2.0:
I'm trying to convert a database from "US" to "METRICWX", but I'm getting this error message:

weectl database reconfigure --config=/etc/weewx/weewx8.conf --dry-run -y

weectl database reconfigure --config=/etc/weewx/weewx8.conf --dry-run -y
Using configuration file /etc/weewx/weewx8.conf
This is a dry run. Nothing will actually be done.
Copying database 'weewx_ecowitt_http_ws6210.sdb' to 'weewx_ecowitt_http_ws6210.sdb_new'
Units will be converted from the 'US' system to the 'METRICWX' system.
Traceback (most recent call last):
  File "/usr/share/weewx/weectl.py", line 75, in <module>
    main()
  File "/usr/share/weewx/weectl.py", line 67, in main
    namespace.func(namespace)
  File "/usr/share/weewx/weectllib/__init__.py", line 90, in dispatch
    namespace.action_func(config_dict, namespace)
  File "/usr/share/weewx/weectllib/database_cmd.py", line 371, in reconfigure_database
    weectllib.database_actions.reconfigure_database(config_dict,
  File "/usr/share/weewx/weectllib/database_actions.py", line 295, in reconfigure_database
    weewx.manager.reconfig(manager_dict['database_dict'],
  File "/usr/share/weewx/weewx/manager.py", line 715, in reconfig
    record_generator = weewx.units.GenWithConvert(old_archive.genBatchRecords(),
                       ^^^^^
UnboundLocalError: cannot access local variable 'weewx' where it is not associated with a value

How can I fix this error?

Tom Keffer

unread,
Nov 3, 2025, 4:18:18 PM (2 days ago) Nov 3
to weewx...@googlegroups.com
I was able to reproduce this. It's an interesting bug. If a schema is named, then the import of "weewx.schemas" is never done, so the package "weewx" will not be defined. Replace your copy of /usr/share/weewx/weewx/manager.py with the attached version and give it another try. 

-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 visit https://groups.google.com/d/msgid/weewx-user/871567a8-e4c3-450a-b398-626657751352n%40googlegroups.com.
manager.py

Werner Krenn

unread,
Nov 4, 2025, 12:16:30 PM (22 hours ago) Nov 4
to weewx-user
Tom
 thanks, it worked.

I have another question:

I'm using additional fields, e.g., "co2_Temp" with the group "group_temperature". To ensure this field is also converted, I'm adding these fields and their group assignments to "units.py".

Could this assignment also be entered into "extensions.py" so that the conversion is performed?

Werner

Tom Keffer

unread,
Nov 4, 2025, 12:54:08 PM (22 hours ago) Nov 4
to weewx...@googlegroups.com
If you added the additional fields in extensions.py you should be OK. That file is imported before starting processing.

Graham Eddy

unread,
Nov 4, 2025, 6:58:32 PM (16 hours ago) Nov 4
to WeeWX User
stregthening tom’s words, it should be added to extensions.py rather than in addition to units.py.
units.py is part of weewx’s code base and subject to updates. extensions.py is the hook to allow custom changes to weewx code base and is not changed by weewx updates.
⊣GE⊢
Reply all
Reply to author
Forward
0 new messages