I think the following VIEW should compensate for the structual change in CMX v4.3 for table DiaryData in SQLite DB diary.db:
4.1.2025/leo: fixed typo in View Definition Timstamp/Timestamp; please note that sqlite versions <3.9 do not support column-name-list in Create View Statement
Code: Select all
CREATE VIEW IF NOT EXISTS VDiaryData (Timestamp, entry, snowFalling, snowLying, snowDepth) AS
SELECT datetime(d,t) AS Timestamp, e AS entry, sf AS snowFalling, sl AS snowLying, sh AS snowDepth FROM
(SELECT Date AS d, Time AS t, Entry e,
CASE WHEN Snow24h > 0 THEN 1 ELSE 0 END AS sf,
CASE WHEN SnowDepth > 0 THEN 1 ELSE 0 END AS sl,
Snow24h AS sh FROM DiaryData);
or without Column-Name-List:
CREATE VIEW IF NOT EXISTS VDiaryData AS
SELECT datetime(d,t) AS Timestamp, e AS entry, sf AS snowFalling, sl AS snowLying, sh AS snowDepth FROM
(SELECT Date AS d, Time AS t, Entry e,
CASE WHEN Snow24h > 0 THEN 1 ELSE 0 END AS sf,
CASE WHEN SnowDepth > 0 THEN 1 ELSE 0 END AS sl,
Snow24h AS sh FROM DiaryData);
Tested within SQLITE3.exe command line tool on a converted TEST CMX 4.3.2 database (but column Snow24h not yet manually adapted and not yet filled out after conversion).
Code: Select all
/* OLD Schema:*/
sqlite> .open C:\Wetterstation.CumulusMX\datav3\diary.db
sqlite> .schema
CREATE TABLE IF NOT EXISTS "DiaryData"(
"Timestamp" datetime primary key not null ,
"entry" varchar ,
"snowFalling" integer ,
"snowLying" integer ,
"snowDepth" float );
sqlite> select * from DiaryData;
2024-12-09 00:00:00||1|0|0.0
2024-12-06 00:00:00||1|1|1.0
2024-12-07 00:00:00||1|0|1.0
2023-11-01 00:00:00||1|0|2.0
2023-02-01 00:00:00||1|0|2.0
2022-05-01 00:00:00||1|0|2.0
2022-12-01 00:00:00||1|0|2.0
/* NEW Schema: */
sqlite> .open C:\Wetterstation.CumulusMX\data\diary.db
sqlite> .schema
CREATE TABLE IF NOT EXISTS "DiaryData" (
"Date" datetime primary key not null ,
"Time" time not null ,
"Entry" varchar ,
"Snow24h" float ,
"SnowDepth" float );
CREATE TABLE dbversion (ver INTEGER PRIMARY KEY);
CREATE VIEW VDiaryData (Timestamp, entry, snowFalling, snowLying, snowDepth) AS
SELECT datetime(d,t) AS Timstamp, e AS entry, sf AS snowFalling, sl AS snowLying, sh AS snowDepth FROM
(SELECT Date AS d, Time AS t, Entry e,
CASE WHEN Snow24h > 0 THEN 1 ELSE 0 END AS sf,
CASE WHEN SnowDepth > 0 THEN 1 ELSE 0 END AS sl,
Snow24h AS sh FROM DiaryData)
/* VDiaryData(Timestamp,entry,snowFalling,snowLying,snowDepth) */;
sqlite> select * from DiaryData;
2022-05-01|00:00:00|||2.0
2022-12-01|00:00:00|||2.0
2023-02-01|00:00:00|||2.0
2023-11-01|00:00:00|||2.0
2024-12-06|00:00:00|||1.0
2024-12-07|00:00:00|||1.0
2024-12-09|00:00:00|||0.0
2025-01-02|00:00:00||1.0|1.0
sqlite> select * from VDiaryData;
2022-05-01 00:00:00||0|1|
2022-12-01 00:00:00||0|1|
2023-02-01 00:00:00||0|1|
2023-11-01 00:00:00||0|1|
2024-12-06 00:00:00||0|1|
2024-12-07 00:00:00||0|1|
2024-12-09 00:00:00||0|0|
2025-01-02 00:00:00||1|1|1.0
Not yet tested with modified snowSumData.php script from Steve. But I will do that after my final CMX 4.3.x converion.
4.1.2025/leo: tested succesfully with CMX 4.3.2 build 4067 and modified php script snowSumData.php v1.2 by replacing table name DiaryData by View name VDiaryData; Adapted the WeatherDiary data via CMX admin interface to fill out the Snow24h values;
see link
https://leonas.ddns.net/Wetterstation.S ... ummary.php
My modified version of snowSumData.php v1.2 that works with CMX 4.3.2 and the new diary.db format (after you created the view) and also works with older PHP 5.3.27 and sqllite 3.7.7.1 can be found in the attachment.