Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions source/_docs/backend/database.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
7 changes: 6 additions & 1 deletion source/_integrations/recorder.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion source/_integrations/sql.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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.

Expand Down