Recorder stoped working - malformed database schema

Today I lost connection with my HA instance running on Raspberry PI 3.
After a hard reset (power off PI and power it on) I saw this in logs:

Error during connection setup: (sqlite3.DatabaseError) malformed database schema (recorder_runs) - unrecognized token: “” (Background on this error at: Error Messages — SQLAlchemy 2.0 Documentation) (retrying in 3 seconds)

I’m aware that I can delete home-assistant_v2.db file, but I start wondering if this could be fixed and how.
I’m sure that I’m not the only one that has or had this error.

Is this a common error? Can it be fixed in another way that deleting the DB? If yes then maybe this could be added into HA?

You could try editing the database with some sort of SQLite editor tool.

Considering the corruption is very unlikely to be the same every time the power is yanked out from under the server I doubt it.

It’s hard to do anything when I don’t have access to the network where the PI is.
I restarted my PI remotely and I connect via Nabu Casa.
I’ll delete the file. If the problem occurs then I’ll search for other solutions. Maybe my SD card is getting corrupted.
P.S. if I’ll clone the card into a new one I can replace the old without any trouble?

I guess you are right about the corruption, it isn’t very often and not everyone is using SQLite, so it would be hard to create a tool that would work for everyone for every use case.