github IAsDoubleYou/homeassistant-mysql_query v1.5.0
Added execute service with structured responses

latest releases: v4.2.1, v4.2.0, v4.1.0...
9 months ago

Structured Response & Error Handling

This version introduces an enhanced service action to provide better feedback and metadata from your MySQL database operations.

🛠 New Feature: mysql_query.execute

This release introduces the execute service. While the existing query service remains unchanged for backward compatibility, the new execute service offers a more detailed response structure.

Key improvements in the execute service:

  • Detailed Metadata: Includes execution time, rows affected, and the exact SQL statement executed.
  • Robust Error Handling: Provides MySQL error numbers (errno) and sqlstate for better debugging in automations.
  • Auto-increment Support: Returns the generated_id (Last Insert ID) directly.
  • Execution Status: A succeeded boolean flag to easily check the outcome of a query.

🤝 Acknowledgments

This update was developed following a request and helpful feedback from @Young-Grandad. I do appreciate the collaboration.

This release addresses and resolves:

  • Issue #13: Provide more details in result (Error, rows affected, last_id)

Quick Example

service: mysql_query.execute
data:
  query: "INSERT INTO sensor_logs (value) VALUES (22.5)"
response_variable: db_result

# You can now easily check the status in your automation:
# {% if db_result.succeeded %} ... {% endif %}

For more details on the new response format, please check the updated README.

Full Changelog: v1.4.1...v1.5.0

Don't miss a new homeassistant-mysql_query release

NewReleases is sending notifications on new releases.