Skip to content

On Home Assistant 2026.10 or older? Open it in HACS

Independent directory, made by the developer of Vulpo. Not affiliated with Home Assistant or the Open Home Foundation.

About

MySQL Query Service is an integration that reads from and writes to a MySQL or MariaDB database through actions. It adds a Query action for statements that only read and an Execute action for statements that change data or schema, and each refuses the other's kind of statement. Both actions can return their result as response data, which can be used from a template. Values can be passed separately from the statement as parameters, and several connections can be configured, with one chosen per call. Safeguards include a row limit, a query timeout, optional read-only connections, and optional TLS encryption that does not verify the server certificate. Connections are set up in the UI and run locally against the database.

Automatic summary of the README and code of IAsDoubleYou/homeassistant-mysql_query. Something wrong, or are you the maintainer and want your own text here? Get in touch

Installs over time

50
Oct 21Nov 9

#1,535 of 1,551 Marketplace integrations. Installs sharing analytics.

Supports

  • Works locallyTalks to your devices on your own network. No vendor cloud in between.
  • From the MarketplaceInstalled through the Marketplace, formerly HACS.
  • Actively maintainedIts author released or pushed a change in the last six months.

Setting it up

Install it from the Marketplace and restart Home Assistant, then add it under Settings, Devices and services.

Connect to your MySQL Database

  • Host
  • Port
  • Username
  • Password
  • Database
  • Connect Timeout (seconds)
  • Query Timeout (seconds)Sets the maximum duration for the entire database operation. If a query exceeds this limit, the action is cancelled and the connection is rebuilt.
  • Charset
  • Collation
  • Autocommit
  • Row Limit (Safety Cap)
  • Encrypt the connection (TLS)Encrypts the traffic to the database. The server must have TLS configured; the connection fails if it does not. The server certificate is not verified, so this protects against reading along on the network, not against a server impersonating yours. Off by default so existing setups keep working.
  • Read-only connectionPrevents write operations from being executed on this connection. Useful to protect connections used only for dashboards and reports against accidental modifications.

Sign in again

  • Username
  • Password

Change the connection

  • Host
  • Port
  • Username
  • PasswordLeave empty to keep the current password. It is not shown here.
  • Database
  • Connect Timeout (seconds)
  • Charset
  • Collation
  • Encrypt the connection (TLS)Encrypts the traffic to the database. The server must have TLS configured; the connection fails if it does not. The server certificate is not verified, so this protects against reading along on the network, not against a server impersonating yours. Off by default so existing setups keep working.

After setup

  • Query Timeout (seconds)Sets the maximum duration for the entire database operation. If a query exceeds this limit, the action is cancelled and the connection is rebuilt.
  • Row Limit (Safety Cap)
  • Autocommit
  • Read-only connectionPrevents write operations from being executed on this connection. Useful to protect connections used only for dashboards and reports against accidental modifications.

Texts from the code of IAsDoubleYou/homeassistant-mysql_query.

Actions

  • ExecuteRuns a statement that changes something (INSERT, UPDATE, DELETE, DDL, and maintenance statements such as ANALYZE or OPTIMIZE) and returns what it affected. Refuses a statement that only reads; use Query for that.
    • Query
    • Values
    • Database override
    • Connection
    • Raise on error
  • QueryRuns a statement that only reads - SELECT, WITH, SHOW, DESCRIBE, EXPLAIN and the like - and returns the rows together with the metadata about the result. Refuses anything that changes data or schema; use Execute for that.
    • Query
    • Values
    • Database override
    • Connection
    • Raise on error

Troubleshooting

  • DiagnosticsDownloads a diagnostics file to attach to a bug report.

From the README

Looking for continuous sensors instead of actions you trigger on demand? See HA MySQL, a sibling integration built for that — full comparison at the bottom of this README.

A Home Assistant custom component that talks to a MySQL or MariaDB database through two actions: mysql_query.query reads with a SELECT and hands you the rows, and mysql_query.execute writes with an INSERT, UPDATE, DELETE or DDL statement and hands you what it changed. Both can return their result as response data you can use straight from a template.

  • UI configuration: add a connection, change it later from the menu of the connection, and sign in again from a prompt when the database refuses the credentials.
  • Reading and writing are separate: query runs only statements that read, execute only statements that change something. The wrong one gives an error naming the right one.
  • Parameterized queries: pass values separately with values and %s placeholders, so the database escapes them for you.
  • Guard rails: a row limit, a query timeout, one statement per call, optional read-only connections, writes for administrators only, and optional TLS.
  • Multiple databases: configure several connections and pick one per call, or use db4query for another database on the same server.
  • Robust: pooled connections, calls on one connection queue instead of interleaving, and a connection that cannot be reached at startup is retried by itself.
  • JSON-safe results: MySQL types such as DECIMAL, DATE and TIME are converted automatically.
From the README of IAsDoubleYou/homeassistant-mysql_query, MIT License. Shortened.

Information

Installs
50 sharing analytics
GitHub stars
17
Connection
Works locally
Upkeep
Updated in the last 6 months
Version
v4.2.1,
Category
DIY and makers, Web and data connectors
Kind
Marketplace integration
Needs
Needs the Marketplace (HACS on 2026.10 and older)
Domain
mysql_query

You might also like

Independent directory, made by the developer of Vulpo. Not affiliated with Home Assistant or the Open Home Foundation. About these numbers

Looking for an app? The best Home Assistant apps for iPhone, by need.