1
0
mirror of https://github.com/home-assistant/core.git synced 2025-05-04 14:09:16 +00:00
G Johansson afa58b80bd
Default to recorder db for SQL integration ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-03-13 17:41:32 -10:00

13 lines
419 B
Python

"""Utils for sql."""
from __future__ import annotations
from homeassistant.components.recorder import get_instance
from homeassistant.core import HomeAssistant
def resolve_db_url(hass: HomeAssistant, db_url: str | None) -> str:
"""Return the db_url provided if not empty, otherwise return the recorder db_url."""
if db_url and not db_url.isspace():
return db_url
return get_instance(hass).db_url