2017-12-06 14:58 GMT+01:00 Simon Slavin <slav...@bigfraud.org>:

>
>
> On 6 Dec 2017, at 1:19pm, Cecil Westerhof <cldwester...@gmail.com> wrote:
>
> >        message          NOT NULL
>
> Given thqt you want the "message" stored as REAL, you should be defining
> this column as REAL.  This is necessary, though not sufficient.


​I only want to store it as a real in this case (or other cases where it is
a real). In other cases I want to store it as text. (Probably most cases.)

But I found the solution. I just rewrote getCPUTemp to:
    proc getCPUTemp {} {
        if {1 != [regexp -all -line {^CPU_TEMP: +\+([0-9.]+)°C } [exec
sensors] -> temp]} {
            error {Did not get exactly a single temperature line from [exec
sensors] output}
        }
        return [expr double(${temp})]
    }

In the return statement I changed the string to double. And who-la it is
stored as real.

​I updated the about 3.000 records with:
    UPDATE messages
    SET    message = CAST(message AS REAL)
    WHERE  TYPEOF(message) = 'text'
       AND type = 'cpu-temp'

-- 
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to