You are my hero!
Thank you so much for sharing!
I tried to follow this guide, but failed.
Home-assistant_v2.db corrupt - How to recover long Term Statistics - Installation / Home Assistant OS - Home Assistant Community
Yours just fixed my issue and I am very grateful for this! (not loosing 12 months of historical energy data)
EDIT: Just for the record…
I just did one thing differently: I did not use the SQLite.exe but logged into my HA host with putty and used the sqlite3 of the HA host.