Hallo Hartmut,

We must be doing something wrong somewhere because the code works for what 
it was intended.

It is missing a call which closes the function update (
> dbmanager_wx.updateValue) and writes to the database
>
> for example --> finally: _cursor.close()
>

The connection is closed when we exit the with statement in def 
clear_v2_data():

with weewx.manager.open_manager_with_config(config_dict, db_binding_wx) as 
dbmanager_wx:

dbmanager_wx is an object of type class Manager() and when we exit the above 
with statement the Manager() __exit__ method is called which handles the 
closure (have a look in bin/weewx/manager.py)

I think there has been quite a few changes since we started on this problem. I 
would like to sit down with the code you are using and try it on a machine here 
and likely put some logging into it so we can see exactly what is going on. Can 
you please post:

1. the python file you are running (modified weewxwd_config ?)
2. the contents of the [DataBindings], [Databases] and [DatabaseTypes] sections 
of weewx.conf
3. the exact command you typed at the command line that did not work

This code is very straightforward, there will be something equally basic that 
is causing the issue.

Gary



On Saturday, 11 March 2017 16:09:05 UTC+10, Hartmut Schweidler wrote:
>
> Hallo,
>
> Supplement
> The function to delete the values  'extraTemp1' and ' extraTemp2' does 
> not work.
>
> if ans == 'y':
>        # we do so go ahead and clear them
>        for _rec in dbmanager_wx.genBatchRecords(start_ts - 1, stop_ts):
>             dbmanager_wx.updateValue(_rec['dateTime'], 'extraTemp1', None)
>             dbmanager_wx.updateValue(_rec['dateTime'], 'extraTemp2', None)
>             nrecs += 1
>            # all done, say so and give some stats
>
> Hartmut
>
>>
>> It is missing a call  closes the function update (
>> dbmanager_wx.updateValue) and writes to the database
>>
>> for example --> finally: _cursor.close()
>>
>> Am Donnerstag, 9. März 2017 17:08:54 UTC+1 schrieb Hartmut Schweidler:
>>>
>>> Hallo Gary,
>>>
>>> You do not have to apologize for anything.
>>>
>>> I have already done this several times
>>>
>>> Right now runs the next attempt instead of outTemp1 with NULL I want to 
>>> replace maxSolarRad with values.
>>> Simply
>>> # we do so go ahead and clear them
>>>                     for _rec in dbmanager_wx.genBatchRecords(start_ts - 
>>> 1, stop_ts):
>>>
>>>                         msr = weewx.wxformulas.solar_rad_Bras(53.605963, 
>>> 11.341407, 53, _rec['dateTime'], 2)
>>>                         dbmanager_wx.updateValue(_rec['dateTime'], 
>>> 'maxSolarRad', msr)
>>>
>>> For security, I just leave the current values per print on the screen 
>>> issue.
>>> In addition, weewx runs normally
>>> result: "cleared in 350828 records (approx 1225 days)" on screen
>>> weewx_copy_fill:  record 350825 unter 128.238500608 tag
>>> weewx_copy_fill:  record 350826 unter 117.421041055 tag
>>> weewx_copy_fill:  record 350827 unter 106.746424888 tag
>>> an in  database NULL, NULL, NULL ....
>>> the funktion from manager:
>>>     def updateValue(self, timestamp, obs_type, new_value):
>>>         """Update (replace) a single value in the database."""
>>>         
>>>         self.connection.execute("UPDATE %s SET %s=? WHERE dateTime=?" %
>>>                                 (self.table_name, obs_type), (new_value, 
>>> timestamp))
>>>
>>> Is called but nothing appears in the database
>>>
>>> Hartmut
>>>
>>

Reply via email to