Merging two weewx databases?

169 views
Skip to first unread message

weerman

unread,
Jan 22, 2020, 2:48:56 PM1/22/20
to weewx-user
Hi everyone,

I would like to ask if it is possible to merge two existing databases with the same name into just one.
I made a mistake during my last update from Build 3.91 to 3.92 and the current database that weewx currently uses is in the "\lib\var\weewx folder.
Using the latest Belchertown template i can only go back to November 1st 2019 to look up my weather reports.
However in the "old" weewx database which is in the "\home\weewx folder i have records going back to 2011.

So is it possible to merge two databases with the same name into just one?

My weatherstation is a WH 1080 btw.

Thanks in advance and best regards

Georg

p q

unread,
Jan 22, 2020, 3:08:01 PM1/22/20
to weewx...@googlegroups.com
Are the schemas the same? (Same data types)

--
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/70625a56-68c7-4e09-8a96-412f12441d3d%40googlegroups.com.

vince

unread,
Jan 22, 2020, 3:09:31 PM1/22/20
to weewx-user
On Wednesday, January 22, 2020 at 11:48:56 AM UTC-8, weerman wrote:
So is it possible to merge two databases with the same name into just one?


Certainly.  Power them both down.  Dump both databases.  Restore both dump files to a new aggregate database.

You should probably just restore the archive table(s) and use wee_database --rebuild-daily to rebuild the summary tables.
Message has been deleted

weerman

unread,
Jan 22, 2020, 3:29:26 PM1/22/20
to weewx-user
Thank you vince. But i'm unsure how to do that. Do i have to use the weewx database commands for that?

BR

Georg

gjr80

unread,
Jan 22, 2020, 3:32:00 PM1/22/20
to weewx-user
A search of the group for ‘merge databases’ will throw up a few threads that cover merging databases including the detailed commands to use.

Gary

weerman

unread,
Jan 22, 2020, 7:11:49 PM1/22/20
to weewx-user


Am Mittwoch, 22. Januar 2020 21:32:00 UTC+1 schrieb gjr80:
A search of the group for ‘merge databases’ will throw up a few threads that cover merging databases including the detailed commands to use.

Gary

Thanks a lot Gary, found and followed a useful one.

However i'm stuck at step 5.
sqlite3 /var/lib/weewx/weewx.sdb
sqlite> .read /var/tmp/old.dump (i renamed the old weewx database into "old.db")
After i entered the latter command, i got an error message "near line XY: attempt to write a readonly database" for every single line.
I have over one million lines in the old database... has it something to do with that error?
Also made sure that weewx isn't running.

Georg




gjr80

unread,
Jan 22, 2020, 8:55:50 PM1/22/20
to weewx-user
Hallo Georg,

When i saw Mittwoch in your reply I thought then that you should look at that thread from early January, it has both English and German, well Google-German!

The readonly database issue is a sure sign that the user account that you are executing the sqlite3 command from does not have sufficient privileges to write to the database file. When you run the sqlite3 command try prefixing it with sudo. So step 5 would be something like this:

$ sudo sqlite3 /var/lib/weewx/weewx.sdb
sqlite
> .read /var/tmp/old.dump

Gary

weerman

unread,
Jan 23, 2020, 6:56:58 PM1/23/20
to weewx-user
Hallo Gary,

Thanks a lot for your help, that fixed the problem.


Beste Grüße / Best Regards

Georg



Reply all
Reply to author
Forward
0 new messages