Is there any way to force HA to sync pending data to database?

I have some scripts that directly query the database home-assistant_v2.db
I want to make sure that all pending or in-memory transactions have been written to the database, especially latest sensor values.

Is there any command I can send that makes sure database is written to other than literally stopping & restarting HA?


My answer to that is this is very dangerous and asking for trouble.

Why don’t you set-up influxdb and query that for whatever?

Because I want to play with the most updated but stable homeassistant_v2.db database and .storage registry files without having to completely stop and restart the ‘ha core’ service.

Aaah, I see your other post. A little context with questions helps you get much better answers.
That looks useful.
Thanks for your contribution to the community.