Page 1 of 1

Database and CumulusMX

Posted: Mon 30 May 2022 2:52 am
by billy
Thought I might give this style a go again - I have always liked it but abandoned it a few years ago. I see in the settings there is room to enter database information but no table information. I already upload realtime data to a MySQL database. Should I be able to use this rather than upload realtime.txt? If so, some clues to how to go about this would be appreciated. Many thanks

Re: Database and CumulusMX

Posted: Tue 31 May 2022 4:14 pm
by rogerthn
Enter Server details
Scroll down to Save Settings, Save and create tables as specified in Table name for Realtime. Dayfile and/or Monthly

Re: Database and CumulusMX

Posted: Wed 01 Jun 2022 1:38 am
by billy
Thanks but I probably didn't make it clear that the settings are for HWS, not CumulusMX. I'm already uploading CMX monthly etc to a MySQL database and wondered if HWS now has a facility to utilize these ... given the option to enter the database details I thought/hoped it might!

Re: Database and CumulusMX

Posted: Wed 01 Jun 2022 3:40 pm
by rogerthn
billy wrote: Wed 01 Jun 2022 1:38 am Thanks but I probably didn't make it clear that the settings are for HWS, not CumulusMX. ...
Correct ;) ;)

Re: Database and CumulusMX

Posted: Fri 03 Jun 2022 4:06 pm
by water01
The best way is to use phpMyAdmin to look at your database and it gives all the table names and their contents.

Re: Database and CumulusMX

Posted: Fri 03 Jun 2022 6:58 pm
by sfws
Since nobody else has answered your actual questions....
billy wrote: Mon 30 May 2022 2:52 am I see in the settings there is room to enter database information but no table information.
The settings you can enter are just to define the way to connect to your database server.

The database name, and table name are both hard-coded into the software as `weatherstation`. As far as I know, the table columns schema (data dictionary) has not been designed to match any default Cumulus table columns schema.
billy wrote: Mon 30 May 2022 2:52 am I already upload realtime data to a MySQL database. Should I be able to use this rather than upload realtime.txt?
The Weather34 Home Weather Station special version for Cumulus realtime.txt was specifically written to use that, but in February 2019 was amended so it can also use meteobridge, weewx, and weathercat realtime.txt. It basically reads the entire file in one command and turns that into a single array with one element for each field.

Ken True updated the script that gets the data so it works with PHP 8 about 6 months ago, he may be able to advise whether a special version of the script could be produced for you.
In theory, a query could read latest row out of your existing table into the same array, the question is what extra work is needed to get the array element keys named/numbered correctly!

Re: Database and CumulusMX

Posted: Fri 03 Jun 2022 7:09 pm
by freddie
sfws wrote: Fri 03 Jun 2022 6:58 pmThe database name, and table name are both hard-coded into the software as `weatherstation`. As far as I know, the table columns schema (data dictionary) has not been designed to match any default Cumulus table columns schema.
billy wrote: Mon 30 May 2022 2:52 am I already upload realtime data to a MySQL database. Should I be able to use this rather than upload realtime.txt?
I don't use Weather34 Home Weather Station, but my understanding is that the special version of that for Cumulus realtime.txt is only able to use that as its input.
Ken True updated the script that gets the data so it works with PHP 8 about 6 months ago, he may be able to advise whether it could be changed to use a query to read your database table, but I suspect it would be a lot of work!
You could do worse than reading up on MySQL views. You could define a view that presents the data from your existing tables in a format that is acceptable to Weather34.

Re: Database and CumulusMX

Posted: Fri 03 Jun 2022 7:35 pm
by sfws
freddie wrote: Fri 03 Jun 2022 7:09 pm You could do worse than reading up on MySQL views. You could define a view that presents the data from your existing tables in a format that is acceptable to Weather34.
I perhaps should have made it clearer, I don't use this software, but just had a quick scan of its code. That made me believe weather34 has no ability to read any database table format, indeed I can't find any code that updates/reads the table it creates! So actually my original drafting of my post was assuming a massive rewrite was needed for any database table usage.

Freddie had posted, quoting my original drafting, before I amended my earlier post when I realised that a query of Cumulus realtime table could produce an array equivalent to that produced from the file, so the only change needed was in that one php script in the second link of my earlier post! My suggestion that the "array element keys" might need remapping, is essentially the same as Freddie is proposing could be achieved via the technical approach of views.

Re: Database and CumulusMX

Posted: Sat 04 Jun 2022 7:10 am
by billy
Your contributions are much appreciated - giving additional clarity of what the current version can and can't do. I'll have a think about whether I will do some bespoke modifications. So, many thanks.