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/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 dd0aeac1dca3..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). @@ -202,7 +204,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.