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) andsqlstatefor better debugging in automations. - Auto-increment Support: Returns the
generated_id(Last Insert ID) directly. - Execution Status: A
succeededboolean 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