Honestly, I know what you're working on as I'm doing the same thing ahah
You should really move to a POSTGRESQL database, for tests you can set it up on the same machine as you're currently using and also download pgadmin for easy visualisation.
I checked a little, you're also storing history data to the SQLite DB, this is far from ideal as SQLite DB is better suited for storing configuration data only. I suspect performing inserts or updates while also storing history tags might cause issues.
When storing tag history to a DB, consider moving to something better suited, such as postgre (free) or MySQL/SQL Server.
+ if at some point we have to merge our work together, postgresql will be our go-to.