---
title: "SQL"
description: "SQL is a built-in integration for Home Assistant. It has 9.2k installs sharing analytics and works locally."
canonical: "https://vulpo.app/integrations/core/sql"
url: "https://vulpo.app/integrations/core/sql.md"
last-updated: "2026-10-22"
version: "1.4"
---

# SQL

> SQL is a built-in integration for Home Assistant. It has 9.2k installs sharing analytics and works locally.

SQL is a built-in Home Assistant integration that turns the results of SQL queries into sensors. Each sensor runs a query that must start with SELECT and uses a chosen column of the result as its state. Optional settings cover the unit of measurement, device class, state class and a value template that extracts a value from the result. The database URL can be left empty, in which case the Home Assistant Recorder database is queried. An action is also available that executes a SQL query and returns the result. Repair notices can appear when a query does a full table scan, and the integration works locally and is set up in the UI.

Automatic summary of Home Assistant's source code. Something wrong? [Get in touch](https://vulpo.app/contact)

[Open in My Home Assistant](https://my.home-assistant.io/redirect/config_flow_start/?domain=sql)

## Supports

- **Works locally**: Talks to your devices on your own network. No vendor cloud in between.
- **Set up in the UI**: Add it in Settings, Devices and services. Nothing to download.
- **Updated with Home Assistant**: Ships and updates with every Home Assistant release.

## Setting it up

It is added under Settings, Devices and services, with Add integration.

### Connect

- **Database URL**: Leave empty to use Home Assistant Recorder database
- **Name**: Name that will be used for config entry and also the sensor

### Options

- **Column**: Column for returned query to present as state
- **Select query**: Query to run, needs to start with 'SELECT'
- **Device class**: The type/class of the sensor to set the icon in the frontend
- **State class**: The state class of the sensor
- **Unit of measurement**: The unit of measurement for the sensor (optional)
- **Value template**: Template to extract a value from the payload (optional)

### After setup

- **Column**: Column for returned query to present as state
- **Select query**: Query to run, needs to start with 'SELECT'
- **Device class**: The type/class of the sensor to set the icon in the frontend
- **State class**: The state class of the sensor
- **Unit of measurement**: The unit of measurement for the sensor (optional)
- **Value template**: Template to extract a value from the payload (optional)

Texts from Home Assistant's source code, [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).

## Actions

- **Query**: Executes a SQL query and returns the result.
  Fields: Database URL, Query

## Troubleshooting

- **Repair notices**: Notices it can show in Settings, Repairs:
  SQL query does full table scan

## At a glance

- Kind: Built-in integration
- Category: [DIY and makers](https://vulpo.app/integrations/category/diy-and-makers.md), Web and data connectors
- Number: 9.2k installs sharing analytics
- Connection: Works locally
- Upkeep: Part of Home Assistant
- Needs: Built into Home Assistant
- Domain: `sql`
- Source: <https://www.home-assistant.io/integrations/sql/>

In Vulpo: Chart card, Apple Watch

Independent directory, made by the developer of Vulpo. Not affiliated with Home Assistant or the Open Home Foundation. [About these numbers](https://vulpo.app/integrations/about)

Last updated 2026-10-22. Source: https://vulpo.app/integrations/core/sql

---

- HTML version of this page: https://vulpo.app/integrations/core/sql
- Site index for agents: https://vulpo.app/llms.txt
- Everything in one document: https://vulpo.app/llms-full.txt
- All pages: https://vulpo.app/sitemap.xml
