Welcome to the Cumulus Support forum.
Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080
Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080
SQL Request
Moderator: mcrossley
-
Mapantz
- Posts: 1992
- Joined: Sat 17 Dec 2011 11:55 am
- Weather Station: Davis Vantage Pro2
- Operating System: Windows 11 x64
- Location: Dorset - UK
- Contact:
SQL Request
Not sure if its possible with the custom SQL uploads or not, but can a Retention String option be added to the Custom upload - seconds interval? Like the Realtime option?
- mcrossley
- Posts: 14388
- Joined: Thu 07 Jan 2010 9:44 pm
- Weather Station: Davis VP2/WLL
- Operating System: Bullseye Lite rPi
- Location: Wilmslow, Cheshire, UK
- Contact:
Re: SQL Request
I can take a look, but the other way to tackle this is to create a post insert trigger on your table that deletes all rows older than the latest row - your retention time.
-
cliftonweather
- Posts: 33
- Joined: Sat 14 Nov 2009 12:34 pm
- Weather Station: Vantage pro+
- Operating System: RPi3 Model 3 running Buster
- Location: Clifton, Beds
- Contact:
Re: SQL Request
Not all MySQL hosts allow the use of triggers, unless you pay for a dedicated server, mine doesn't (which is annoying). But there are other methods, if you terminate your SQL in the Custom Upload box with a semicolon you can then run another SQL command, something like:-
DELETE FROM YourTableName WHERE LogDateTime < DATE_SUB(NOW(), INTERVAL 7 DAY); to keep a week
DAY can be replaced with SECOND, MINUTRE, HOUR etc.
Or you can create a procedure with the DELETE SQL in it and use:-
CALL YourProcedureName(); after your SQL.
Hope this helps
DELETE FROM YourTableName WHERE LogDateTime < DATE_SUB(NOW(), INTERVAL 7 DAY); to keep a week
DAY can be replaced with SECOND, MINUTRE, HOUR etc.
Or you can create a procedure with the DELETE SQL in it and use:-
CALL YourProcedureName(); after your SQL.
Hope this helps
- mcrossley
- Posts: 14388
- Joined: Thu 07 Jan 2010 9:44 pm
- Weather Station: Davis VP2/WLL
- Operating System: Bullseye Lite rPi
- Location: Wilmslow, Cheshire, UK
- Contact:
Re: SQL Request
Good idea about using the custom update.
Re-Triggers, if you do have them, then I actually put the trigger on the full log table - that way the "housekeeping" only gets done every 5-10 minutes (depending on you log interval) rather than every few seconds.
Re-Triggers, if you do have them, then I actually put the trigger on the full log table - that way the "housekeeping" only gets done every 5-10 minutes (depending on you log interval) rather than every few seconds.
-
Mapantz
- Posts: 1992
- Joined: Sat 17 Dec 2011 11:55 am
- Weather Station: Davis Vantage Pro2
- Operating System: Windows 11 x64
- Location: Dorset - UK
- Contact:
Re: SQL Request
Sweet! I didn't know you could add multiple commands, not in CMX anyway. That's very helpful and it's working. You learn something new every day!cliftonweather wrote: ↑Sun 15 Mar 2020 9:23 am if you terminate your SQL in the Custom Upload box with a semicolon you can then run another SQL command, something like:-
DELETE FROM YourTableName WHERE LogDateTime < DATE_SUB(NOW(), INTERVAL 7 DAY); to keep a week
DAY can be replaced with SECOND, MINUTRE, HOUR etc.
Hope this helps