MySQL Command

Hi,

Over the past few days I decided to try to solve the problem and succeeded.
I’ve created a custom service that will handle what we were after.
The service takes an sql query as input and fires it against the MySQL database that has been configured in the configuration.yaml
After invoking the service it responds with an iterable structure that contains the requested values.

For testing purposes i have used the output of a query that returns 3 columns and sends it through the gmail notification service from within an automation.

The query should be written in the form:
select col1, col2, col3,...|* from <table> [where condition]

examples:
select * from contacts
select name, phonenumber from contacts where language='nl'

Since this is just my second python project i’m sure there is still enough to brush up :wink:

Also since i haven’t published anything through HACS yet, it will cost me some extra time to figure that out too.

Inspired by the topicstarter (@qrioniclabs) i named the project: homeassistant-mysql_query.

2 Likes