That's not the way the database manager works. There are three
possibilities:

1. 'rainRate' is not in the schema. Result: exception of type
weedb.OperationalError is raised.
2. 'rainRate' in the schema, but a record with the timestamp is not in the
database. Result: value 'None' is returned (rr = None)
3. 'rainRate' in the schema, and record with the right timestamp is in the
database. Result: rr[0] will hold the value of 'rainRate'. It could be
None, or it could be a floating point.

#2 is what is happening here.

On Thu, Apr 4, 2019 at 5:49 AM Luc Heijst <ljm.hei...@gmail.com> wrote:

> On Thursday, 4 April 2019 09:31:11 UTC-3, Thomas Keffer wrote:
>>
>> The problem here is that the record itself was not in the database.
>>
>
> I see it different.
> The value in the database is None because no loop value was received when
> the record was written.
> The value for rr is None.
> The exception says: TypeError: 'NoneType' object has no attribute
> '__getitem__'
> Thus: rr[0] throws an error.
> Solution [not tested]:
>         try:
>             rr = dbmanager.getSql('select rainRate from %s where
> dateTime=?' %
>                                   dbmanager.table_name, (r['dateTime'],))
>         except weedb.OperationalError:
>             pass
>         else:
>             if rr is not None:
>                 r['rainRate'] = rr[0]
>             else:
>                 r['rainRate'] = None
>         return r
>
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to