From e45839df025ce401d6d113d5ed360b38ebe8301e Mon Sep 17 00:00:00 2001 From: mik-laj <12058428+mik-laj@users.noreply.github.com> Date: Sat, 2 May 2026 21:10:28 +0200 Subject: [PATCH 1/2] Add cross-references between database docs and SQL integration Link the database documentation page to the SQL sensor integration and vice versa, so readers can discover both tools for exploring the recorder database. Co-Authored-By: Claude Sonnet 4.6 --- source/_docs/backend/database.markdown | 6 ++++++ source/_integrations/sql.markdown | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/_docs/backend/database.markdown b/source/_docs/backend/database.markdown index 734c34f40ebd..774d2016eb35 100644 --- a/source/_docs/backend/database.markdown +++ b/source/_docs/backend/database.markdown @@ -263,4 +263,10 @@ group.all_switches 8018 If you don't want to keep certain entities, you can delete them permanently by using the [actions provided by the recorder](/integrations/recorder/#action-purge_entities). +### Use the SQL sensor for live queries + +Beyond manual exploration, you can run SQL queries directly inside Home Assistant using the [SQL](/integrations/sql/) {% term integration %}. It connects to the same recorder database by default and lets you expose query results as sensor entities, or call queries from automations using the `sql.query` action — no external tools needed. + +### Data Science Portal + For a more interactive way of working with the database, check the [Data Science Portal](https://data.home-assistant.io/). diff --git a/source/_integrations/sql.markdown b/source/_integrations/sql.markdown index dd0aeac1dca3..2205d50d5dff 100644 --- a/source/_integrations/sql.markdown +++ b/source/_integrations/sql.markdown @@ -202,7 +202,7 @@ result: See [supported engines](/integrations/recorder/#custom-database-engines) for which you can connect with this integration. -The SQL integration will connect to the Home Assistant Recorder database if "Database URL" has not been specified. +The SQL integration will connect to the Home Assistant Recorder database if "Database URL" has not been specified. For a full overview of available tables, columns, and indexes in that database, see the [Database](/docs/backend/database/) documentation. There is no explicit configuration required for attributes. The integration will set all columns returned by the query as attributes. From a6122ba0693bfb969bc8b2e8ca095f7b92a2b3ce Mon Sep 17 00:00:00 2001 From: mik-laj <12058428+mik-laj@users.noreply.github.com> Date: Sat, 2 May 2026 21:49:13 +0200 Subject: [PATCH 2/2] fixup! Add cross-references between database docs and SQL integration --- source/_integrations/recorder.markdown | 7 ++++++- source/_integrations/sql.markdown | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/_integrations/recorder.markdown b/source/_integrations/recorder.markdown index 3fc617d7b7df..a1cd5d37efa5 100644 --- a/source/_integrations/recorder.markdown +++ b/source/_integrations/recorder.markdown @@ -10,6 +10,11 @@ ha_iot_class: Local Push ha_codeowners: - '@home-assistant/core' ha_integration_type: system +related: + - docs: /docs/backend/database/ + title: Database schema + - docs: /integrations/sql/ + title: SQL integration --- The **Recorder** {% term integration %} is by default enabled as dependency of the [`history`](/integrations/history/) integration. @@ -28,7 +33,7 @@ The supported database solutions are: Although SQLAlchemy supports database solutions in addition to the ones supported by Home Assistant, it will behave differently on different databases, and features relied on by the recorder may work differently, or not at all, in different databases. -The default, and recommended, database engine is [SQLite](https://www.sqlite.org/) which does not require any configuration. The database is stored in your Home Assistant configuration directory ('/config/') and is named `home-assistant_v2.db`. +The default, and recommended, database engine is [SQLite](https://www.sqlite.org/) which does not require any configuration. The database is stored in your Home Assistant configuration directory ('/config/') and is named `home-assistant_v2.db`. For details on the database structure, including available tables and columns, see the [Database](/docs/backend/database/) documentation. {% caution %} Changing database used by the recorder may result in losing your existing history. Migrating data is not supported. diff --git a/source/_integrations/sql.markdown b/source/_integrations/sql.markdown index 2205d50d5dff..83e8986a59f3 100644 --- a/source/_integrations/sql.markdown +++ b/source/_integrations/sql.markdown @@ -17,6 +17,8 @@ ha_integration_type: integration related: - docs: /docs/configuration/ title: Configuration file + - docs: /docs/backend/database/ + title: Database schema --- The **SQL** {% term integration %} enables you to use values from an [SQL](https://en.wikipedia.org/wiki/SQL) database supported by the [sqlalchemy](https://www.sqlalchemy.org) library, to populate a sensor state (and attributes).