I have a sensor to track the size of my database (defined in a YAML file for quite some time).
It has never really bothered me, but recently I noticed that I only have the last 10 days of history. I can’t go back any further, unlike all my other sensors for which I have history/stats from the beginning (2-3 years).
SQL integration creates an attribute for each column in the output. From what I can see, you can just remove table_schema "homeassistant", from the select command as it is not needed for anything anyway.
Edit: or rename it to “database”: SELECT table_schema "database", Round...
11 days have passed, and it seems that correcting the SQL query to a single output value, has resolved the issue.
I now have long term statistics with this sensor, whether it’s created within the YAML file, or from the SQL UI integration.