Hallo Hartmut, My apologies have been otherwise busy. I think you are making this much harder than it need be.If you have a database, let's call it database A, to which you want to add historical maxSolarRad data then the following should work: 1. make a backup of database A in case things go badly wrong 2. add the field maxSolarRad to the archive table in database A 3. run the modified --clear-v2-data to calculate maxSolarRad for each record in the database A archive table. Use the --wd-binding=xxxxxxx, where xxxxxxx is the binding in weewx.conf for database A. 4. drop then rebuild the daily summaries
There is no need to make copies of database A with --create-archive and/or --copy-v2-data. You should be able to run the modified --clear-v2-data whilst weeWX continues to run as it will mainly only be accessing historical archive table records and I doubt it or weeWX will run into database lock issues unless the both happen to try to modify the current (ie latest) record at the same time. Step 1 can be done with mysqldump, its covered in the first step in this wiki entry <https://github.com/weewx/weewx/wiki/Transfer%20from%20MySQL%20to%20sqlite>. I believe you have already done step 2. You have already created the modified --clear-v2-data, it is just a case of using it with the correct binding for database A. The above steps could be expanded to add cloudbase and windrun by adding the extra fields at step2 (again I believe you have already done this) and uncommenting a few lines in your already modified --clear-v2-data code. Step 4 is the last thing we do once all the data is in the archive. --clear-v2-data may take a long time to complete but since weeWX continues to run it should not result in any lost data. Gary On Wednesday, 8 March 2017 01:47:11 UTC+10, Hartmut Schweidler wrote: > > Hallo Gary, > > 1. I have created a copy of weewxacer database > > 2. the function record_generator = *WdGenerateDerived* > (dbmanager_wx.genBatchRecords (start_ts - 1, stop_ts)) changed > > 3. weewxwd3.py *WdGenerateDerived *habe a look at weewxwd3.py > > 4. I have run the procedere from weew wd > > > https://bitbucket.org/ozgreg/weewx-wd/src/110688ada0c69c43912a93725976091278c2bb60/?at=v1.2.0_development > > - create the Weewx-WD database and archive table: > > weewxwd_config --create-archive (((weewxacerWD)))) > > - check if there is any legacy data to copy, or if any historical > Weewx-WD data can be reconstructed: > > weewxwd_config --status > > - copy any legacy data or reconstruct any historical Weewx-WD data: > > weewxwd_config --copy-v2-data (((from weewxacer to weewxacerWD))) > > After 17 hours I had a copy of the weewxacer as weewxacerWD database > the weewxacer database the old > the weewxacerWD one kopie of the old weewxacer-database and the newly > calculated values > > all TEST TEST TEST > Only for the calculation of about 300 values I will not take my original > weather database 17 hours offline. > > 17 hours offline at the davis should not be a problem > > however the o-wire temperature, water-temperature-sensors does not store any > data > I am looking for a simple update solution > > for example > > #!/usr/bin/python >> # -*- coding: utf-8 -*- >> import MySQLdb as mdb >> import sys >> try: >> conn = mdb.connect('localhost', 'testuser', >> 'test623', 'testdb'); >> For "first Time in weewx-database" to "last Time in weewx-database" step 1: >> cursor = conn.cursor() >> cursor.execute("UPDATE archive SET maxSolarRad = %s WHERE dateTime = >> %s", ("123.98", "1394092770")) >> cursor.execute("UPDATE archive SET windRun = %s WHERE dateTime = %s", >> ("233.08", "1394092770")) >> cursor.execute("UPDATE archive SET cdIndex = %s WHERE dateTime = %s", >> ("45.7", "1394092770")) >> >> and so on.. > >> conn.commit() >> cursor.close() >> conn.close() >> """ >> >> > Format-compliant to weewx as a updateDB.py > > > hartmut > >
