Here's an ONLY PARTIALLY TESTED suggestion using the sqlite3 utility 
program.  Like you said, you should only try this on copies
of both databases.  Then when you're satisfied, you can replace your live 
database with the fixed copy.

Start sqlite3, attach both the "good" and the "bad" databases, then execute 
an UPDATE statement for a range of dates.  In this example, db1 is the
database that gets fixed, and db2 has the correct rain values.

.attach database 'weewx.sdb' as db1
.attach database 'weewx2.sdb' as db2
update db1.archive set rain = (select rain from db2.archive where 
db1.archive.datetime == db2.archive.datetime)
 where date(db1.archive.datetime, 'unixepoch', 'localtime') between 
'2021-01-01' and '2021-05-01';
.exit

Then I'd start sqlite3 again and do some select queries to validate that 
all is good in db1.

Walt

On Saturday, May 8, 2021 at 10:26:52 AM UTC-5 [email protected] wrote:

> I actually expected an answer like this. I'm not trying to be an ass, but 
> if you don't have the answer to my dilemma, you could just scroll on down 
> to the next post. But yes, I did use Google. Found some things about 
> "joining" databases. I'm just worried about compromising the integrity of 
> the database by doing that. Of course, I'd make a backup first. I didn't 
> find anything specific about copying certain time ranges.
>  
> I figured someone here would have already been in the same boat I am and 
> have already gone through the process.
>  
> Thanks anyway.
>
> On Sat, May 8, 2021 at 11:10 AM p q <[email protected]> wrote:
>
>> Have you tried googling for inserting into a sqlite db from another? I'm 
>> not trying to be an ass, but if I had the problem you describe thats what 
>> I'd do. I'm sure there's sql you could use but I don't do it all the time 
>> and would have to look it up. 
>>
>> On Sat, May 8, 2021, 7:46 AM Ernest Jillson <[email protected]> wrote:
>>
>>> I imported years of data from wunderground into my weewx db. There was a 
>>> period of very bad rain data due to a malfunctioning tipping bucket. Also 
>>> had a day where a small grasshopper managed to get into the little hole, 
>>> then proceeded to rack up about 15 inches of rain for me that day while 
>>> trying to escape.
>>>  
>>> I stopped weewx, made a copy of my db, then used sqlite browser to 
>>> remove all of the bad rain data, day by day, week by week. When I was 
>>> satisfied, I restarted weewx and life was good.
>>>  
>>> It wasn't until a month later, while flipping through some of my past 
>>> data that I realized I had somehow managed to remove much more data than I 
>>> wanted to. I mean, we're talking like a year's worth of rain data.
>>>  
>>> I don't want to import those days all over again, but I can if that's 
>>> the only way. I'd much rather like to find a way to "bring over" the rain 
>>> from the saved database for a range of dates, then start the fixing process 
>>> again. When I brought the data over from wunderground, there were lots of 
>>> dew point/humidity and temperature anomolies I had to fix as well.
>>>  
>>> My question:  Is there a way (perhaps using the sqlite browser) to 
>>> import a column (rain) from one database (the saved one) to the new 
>>> database for just a range of dates?
>>>  
>>> Thanks in advance!
>>>
>>> -- 
>>> 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 [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/weewx-user/CAC5oUmN6qQVrx0YTCLHhkKRdxJAg7%3DEjtcwDkudBO8bzJm956A%40mail.gmail.com
>>>  
>>> <https://groups.google.com/d/msgid/weewx-user/CAC5oUmN6qQVrx0YTCLHhkKRdxJAg7%3DEjtcwDkudBO8bzJm956A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> -- 
>> 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 [email protected].
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-user/CAA1SM22%2BL2zPhtr205-aO5RmZ%3DSr-LheKcSsw6vP%2Bm3gw-uOnA%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/weewx-user/CAA1SM22%2BL2zPhtr205-aO5RmZ%3DSr-LheKcSsw6vP%2Bm3gw-uOnA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/d2fc4b96-5d21-4532-9f49-0ec4cff7c97cn%40googlegroups.com.

Reply via email to