Restore use of local timezone for MariaDB/MySQL in SQL integration (#91313)

* Use local timezone for recorder connection

The fix in #90335 had an unexpected side effect of
using UTC for the timezone since all recorder operations
use UTC. Since only sqlite much use the database executor
we can use a seperate connection pool which uses local time

This also ensures that the engines are disposed of
when Home Assistant is shutdown as previously we
did not cleanly disconnect

* coverage

* fix unclean shutdown in config flow

* tweaks
This commit is contained in:
J. Nick Koston
2023-04-12 20:24:55 -04:00
committed by GitHub
parent 2d1ae6660b
commit 4366f83ac8
5 changed files with 124 additions and 8 deletions
+16
View File
@@ -0,0 +1,16 @@
"""The sql integration models."""
from __future__ import annotations
from dataclasses import dataclass
from sqlalchemy.orm import scoped_session
from homeassistant.core import CALLBACK_TYPE
@dataclass(slots=True)
class SQLData:
"""Data for the sql integration."""
shutdown_event_cancel: CALLBACK_TYPE
session_makers_by_db_url: dict[str, scoped_session]