When this was working, the code DID insert numeric values into the database. I have a screenshot of the database but this forum chat refuses to accept my dropbox images and I cannot directly upload from my laptop. With that said, when the variable results[Hot_Fluid_Temp] (as well as the other 3) was given to the Mariadb line to insert, it would insert a set of 4 numbers, each to 4 decimal places....I had as many as 34 pages of 25 lines of solar heater temps, right tank, left tank, and air temps. Something happened in mid March that caused the program to stop autonomously record every 10 minutes. Now I get the KeyErrors no matter what I try.I take it you've seen this posting for MariaDB with Python https://mariadb.com/resources/blog/how- ... o-mariadb/.The scope of this project is to take temperature readings from the arduino (which is controlling much more than just temps btw), insert them into the assigned database,
I suspect that you are not matching the data type from the Python with MariaDB support data types. See https://mariadb.com/kb/en/data-types/. Unless stated for MariaDB, will not be any coversion.
I could figure out where some of the values were coming from in the code nor did you provide the schema of the DB. Here's an example I hope illustrates taking the Python data and converting it to something to write to the DBCode:
>>> t=['HotFluidTemp', ' 69.12']>>> type(t)<class 'list'>>>> x=t[1]>>> x' 69.12'>>> type(x)<class 'str'>>>> y=float(x)>>> y69.12>>> type(y)<class 'float'>>>>
The database is set up where all 4 variables are int(10,4). 10 characters with 4 decimal places. I believe the OS to be Bullseye. Earlier today, I had the pleasure of literally frying the Pi that was running this show and just found another Pi3b+ I had in a drawer...and found out it doesn't have wifi...now the hunt begins for my wifi dongle I keep around.
As soon as I have wifi back up in my garage, I will provide the schema of the database as well as examples that it was working.

In your code, x does return that number. x=0 would return HotFluidTemp and x=1 would return the value. Yet...when the program jumps to the INSERT into heater line....I get KeyErrors and it's almost always the last variable "AirTemp". In the example I typed out, AirTemp reports the same as the previous 3...so why wouldn't the KeyError not be produced at the very first since the database is set up with all 4 being identical? This is what is strange to me. A list starts with 0. I'm cool with that. The number 2 and 3 should return RIGHT_TANK_TEMP and its value. What I get is something out of index or something...I don't recall and am trying to remember this from my head. This baffles me. If I am dealing with 0 and 1 on each data set from the Arduino...how do I differentiate between them to pull only the numerical numbers only? I even tried rtt = results[parts[3]] to pull only the RightTankTemp number. Error. Tried rtt = results[3] - got an error. It only accepts 0 and 1. 4 sets...this all makes my brain hurt literally and being that I am having surgery on Friday...pain meds are not wanted in my system beforehand

Statistics: Posted by Osprey72 — Wed Apr 17, 2024 12:21 am