Moving a database from CentOS to Raspbian and a database error

40 views
Skip to first unread message

WindnFog

unread,
Sep 1, 2019, 10:45:30 AM9/1/19
to weewx-user

Here's the context. My weakness is understanding databases in general. For almost 4 years, I have been weewx on a CentOS system capturing data from a Vantage Vue Console. My weewx.sdb file has nearly 4 years of historical data. That's the workhorse and is chugging along nicely.  


A week ago, I set up a parallel system on a Raspberry Pi 4 with a second Vantage Vue Console. That works well. The goal is to replace the CentOS system with the Pi. Two days ago, I renamed the weewx.sdb file on the new system, and replaced it with a copy of the one from the CentOS setup. The idea was to start adding data from the logger to the original database. I am getting the following error:


"**** Unit system of incoming record (0x01) differs from 'archive' table in 'weewx.sdb' database (0x10)"


I note that in 2018 someone else had the same error and asked the group for help. Tom's response was, "Here's the most likely explanation: When you first started weeWX, you used a database in US units. Then you tried to change it to Metric. As explained in the User's Guide, 'Once chosen, [the unit system] cannot be changed! WeeWX does not allow you to mix unit systems within the databases. You must choose a unit system and then stick with it.' If you did not try to change unit systems, then it must be something else."


I know I set up the Pi a week ago as metric. I don't remember how I set up the original CentOS instance. I may well have used US units because I was a weewx newbie at the time. I *think* one can do that and still display them as metric if you configure the skin.conf and/or weewx.conf file accordingly. All of my display data is metric.


I have spent a couple of days reading the documentation. The database sections aren't clicking with me. If there's a way out of this, I can't see it (or understand it.)


That's the situation. My questions are: 


(1) How can I find out which units the original weewx.sdb is using?

(2) If they are US, is there a utility or way to export them and then import them into a metric system?

(3) If there is no way, is the best way out of this to set up the Pi again using US units? I assume if the old system is US and working and displaying metric units, I can do the same on my new installation.


While I'm hesitant to ask what may be a questions with obvious answers, for the life of me I can't find them in the documention or on the Internet.


Paul VE1DX

Thomas Keffer

unread,
Sep 1, 2019, 11:05:05 AM9/1/19
to weewx-user
I don't think this has to be a problem: just change the unit system on the Pi, so it matches the unit system of the database file from the old CentOS system, METRICWX: 

[StdConvert]
    # DO NOT MODIFY THIS VALUE UNLESS YOU KNOW WHAT YOU ARE DOING!
    target_unit = METRICWX    # Options are 'US', 'METRICWX', or 'METRIC'

NB: This is why that warning is there! Not only that, but the Vantage series emits data in the US Customary system, so the converted data will have lots of digits beyond the decimal point, making it less readable.

To answer your other questions:

1. Try this

sqlite3 weewx.sdb
select min(usUnits), max(usUnits) from archive;

This will show one of

1|1:  Us Customary
10|10: Metric
11|11: MetricWX

anything else and you've got mixed units in your database.

2. Yes, this can be done. You use the utility wee_database with the --reconfigure option. But, why do it?

3. Yes. The units in the database are completely independent of the units used for reporting. The former should be optimized around the hardware you are using, which, in your case, is US Customary. The latter are about your locale, which means setting the various unit groups to metric units.

-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/58de53f1-f8a4-4bbb-97c2-a4dabc949f46%40googlegroups.com.

WindnFog

unread,
Sep 1, 2019, 12:22:42 PM9/1/19
to weewx-user
Thank you, Tom.  Changing the target_unit fixed it.  I surw didn't want to lose my historical data.  Everything seems fine with the Pi now, so I'll let it run for a few days and then cut over to it for "production."  There's no point in running a suitcase-sized system when you can do it on a system the size of a credit card.

Out of curiousity, how could one get mixed units in the database?

- Paul VE1DX

Thomas Keffer

unread,
Sep 1, 2019, 2:03:16 PM9/1/19
to weewx-user
Out of curiousity, how could one get mixed units in the database?


The current version of weewxd won't let you do it, but earlier version were not so hard-nosed. 
Reply all
Reply to author
Forward
0 new messages