# \[APP\]\[PRO\] MySQL-Client

**URL:** <https://community.homey.app/t/app-pro-mysql-client/62459>\
**Category:** Apps\
**Tags:** app, tools, homey-pro\
**Created:** [April 7, 2022, 7:18pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459 "2022-04-07T19:18:16Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [April 12, 2022, 4:57pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/21 "2022-04-12T16:57:59Z")

</div>

Another example:

My table “power\_daily” - power usage with daily usage and meter:

 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/5/6507fdababac011a0be3efd14754d63d11995dbd.png)

First Flow to select the last meter value (last day), starting at new day (00:00):  
[https://homey.app/de-de/flow/OdxIu0/](https://homey.app/de-de/flow/OdxIu0/)

Second flow: Read selected value, calculate gap to new meter value and store the two values (and date) as new line:  
[https://homey.app/de-de/flow/o7UIu0/](https://homey.app/de-de/flow/o7UIu0/)

I have another one for hourly updates. Every time the same logic, but with time in addition:

 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/d/5d25e84ca1c335f2e7c8aede8b8cab9cbac61e68.png)  
[https://homey.app/de-de/flow/tqFLu0/](https://homey.app/de-de/flow/tqFLu0/)  
[https://homey.app/de-de/flow/fRILu0/](https://homey.app/de-de/flow/fRILu0/)

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [April 12, 2022, 5:05pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/22 "2022-04-12T17:05:04Z")

</div>

PS: I use a Windows client for DB changes. It’s much easier than phpMyAdmin on the NAS.

My Favorite:  
[https://dev.mysql.com/downloads/workbench/](https://dev.mysql.com/downloads/workbench/)

Nice, too:

> **[Download HeidiSQL](https://www.heidisql.com/download.php)**
>
> Download your free copy of HeidiSQL here. Or download the sources.

---

<div class="post-metadata">

**Author:** ![Undertaker](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/undertaker/32/53278_2.png) [@Undertaker](https://community.homey.app/u/Undertaker)\
**Post date:** [April 12, 2022, 5:23pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/23 "2022-04-12T17:23:33Z")

</div>

Thank you for your help ! I still have a lot to learn and more to do on the subject.

Works:

![Screenshot_20220412-192148_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/8/589dea354c3cb8d39ed5c83a4d414944a2745f36.jpeg)  
Something to play again…😇

---

<div class="post-metadata">

**Author:** ![romiwi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/romiwi/32/9662_2.png) [@romiwi](https://community.homey.app/u/romiwi)\
**Post date:** [April 12, 2022, 9:47pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/24 "2022-04-12T21:47:29Z")

</div>

Sorry, this might be a silly question, but how do i initially connect to a mysql db😔? After installing the mysql client app in homey, i wanted to create a flow, however when adding a card, i dont have the choice of the mysql object, neither in the ‘if’ nor in the ‘then’ section…thanks for your help!

---

<div class="post-metadata">

**Author:** ![Robin\_van\_Kekem](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robin_van_kekem/32/8187_2.png) [@Robin\_van\_Kekem](https://community.homey.app/u/Robin_van_Kekem)\
**Post date:** [April 12, 2022, 9:49pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/25 "2022-04-12T21:49:02Z")

</div>

After installation of the app you need to add an ‘device’ which connects to your DB

---

<div class="post-metadata">

**Author:** ![romiwi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/romiwi/32/9662_2.png) [@romiwi](https://community.homey.app/u/romiwi)\
**Post date:** [April 20, 2022, 6:41am UTC](https://community.homey.app/t/app-pro-mysql-client/62459/26 "2022-04-20T06:41:42Z")

</div>

Thanks !

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [May 6, 2022, 7:47pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/27 "2022-05-06T19:47:01Z")

</div>

With test version 0.0.7 you can **use a SQL query in flow conditions**. Select one (!) field from your DB table and use the result (as number or text) in a flow condition. Compare numbers (greater or lower-equal; equal or not equal) or text (equal or not equal).

![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/7/3722c758e35997a364683caf124edc3bbb47a101.png)

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [May 10, 2022, 4:41pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/28 "2022-05-10T16:41:04Z")

</div>

New test version 0.0.9:

- Added a **new flow condition for** “SQL query was successful”.
- Added capabilities/tokens for the quer result:  
 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/f/9f88a58264859c935ea9ba7a35c56c8c0435124b.png)  
This capabilities will be set witch each query. You can use these capabilities as **global token in your flow** :  
 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/b/bb4abafa8833dc2b21b1182e5764af9bb3aaf4b9.png)

Token:  
 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/d/4d8ec236a878b024dcf290eafbeff2d2b90ef724.png)  
 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/4/44618a897fa76684dc1bcf1d4fd8d0fb05126654.png)

---

<div class="post-metadata">

**Author:** ![Jacco](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jacco/32/12914_2.png) [@Jacco](https://community.homey.app/u/Jacco)\
**Post date:** [May 13, 2022, 10:55am UTC](https://community.homey.app/t/app-pro-mysql-client/62459/29 "2022-05-13T10:55:09Z")

</div>

When I use [date-1d] in my query it doesn’t give the date but only ‘2005’

INSERT INTO Power (date, power\_usage) VALUES ([date-1d], value)

What is wrong?

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [May 13, 2022, 12:48pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/30 "2022-05-13T12:48:20Z")

</div>

I have to check if this calculation is affected by the changed zimezone handling. I assume you have upgraded to 7.4.x?

---

<div class="post-metadata">

**Author:** ![Jacco](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jacco/32/12914_2.png) [@Jacco](https://community.homey.app/u/Jacco)\
**Post date:** [May 13, 2022, 12:54pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/31 "2022-05-13T12:54:07Z")

</div>

I running 7.3 , can this be the issue?

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [May 13, 2022, 1:04pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/32 "2022-05-13T13:04:08Z")

</div>

No, perhaps I inserted a bug with the 7.4 adaption. But with 7.3 I can test this issue and know where to start my search - have not upgraded yet 😁

I’ll check it this evening and send you an update. Thanks for the hint.

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [May 13, 2022, 1:47pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/33 "2022-05-13T13:47:18Z")

</div>

Too easy … it’s not a bug, but a misinterpretation of your field value by SQL.

You missed the quotes around your date value… See the example in post #2:  
 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/d/bd2f37abe311135e44f03ff4829798a9a40b94a7.png)

With quotes, the date is inserted as string in the format “2022-05-12” and the database is reading this as a valid date.  
Without quotes, you will get 2022-05-12 and SQL is interpreting as numbers with substraction - and you get 2005 as result.

So please add quotes arounf the date and it should store the correct date.

Example for date usage: [Date Functions in SQL Server and MySQL](https://www.w3schools.com/sql/sql_dates.asp)

---

<div class="post-metadata">

**Author:** ![Jacco](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jacco/32/12914_2.png) [@Jacco](https://community.homey.app/u/Jacco)\
**Post date:** [May 13, 2022, 2:45pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/34 "2022-05-13T14:45:24Z")

</div>

INSERT INTO Power (date, power\_usage) VALUES (‘[date-1d]’ , value);

Give an error.  
Error in SQL query: Unknown column “2022’ in ‘field list’

Without quotes no error but 2005 as result

Same result when using the date variable

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [May 13, 2022, 2:46pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/35 "2022-05-13T14:46:55Z")

</div>

There’s a difference between ` and ’

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [May 13, 2022, 2:59pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/36 "2022-05-13T14:59:54Z")

</div>

Please use simple single quotes, no apostrophe.  
Double quotes should be ok, too. But don’t use special Unicode characters. That does not correspond to the SQL syntax.

---

<div class="post-metadata">

**Author:** ![Jacco](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jacco/32/12914_2.png) [@Jacco](https://community.homey.app/u/Jacco)\
**Post date:** [May 13, 2022, 4:16pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/37 "2022-05-13T16:16:10Z")

</div>

ok, I wrote the query from my iPad, now I did it from my windows laptop at it is working.

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [May 13, 2022, 9:10pm UTC](https://community.homey.app/t/app-pro-mysql-client/62459/38 "2022-05-13T21:10:53Z")

</div>

New version 0.0.10:  
Only some bugfixes

- token update (synchron to work with toke in the next condition).
- timezone fix for [date] calculation. The timezone was added two times. That results in a duplicated offset which could affect the result date if the second timezone offset is hitting the 0:00 border.

---

<div class="post-metadata">

**Author:** ![Jacco](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jacco/32/12914_2.png) [@Jacco](https://community.homey.app/u/Jacco)\
**Post date:** [May 14, 2022, 8:44am UTC](https://community.homey.app/t/app-pro-mysql-client/62459/39 "2022-05-14T08:44:05Z")

</div>

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/2/72200692a9718a18dfa1d5b34968716074452571.png)

When I place the global tokens also between single quotes it is working fine.

Thanks.

---

<div class="post-metadata">

**Author:** ![M\_a\_r\_c\_o](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/m_a_r_c_o/32/146_2.png) [@M\_a\_r\_c\_o](https://community.homey.app/u/M_a_r_c_o)\
**Post date:** [May 15, 2022, 10:48am UTC](https://community.homey.app/t/app-pro-mysql-client/62459/40 "2022-05-15T10:48:34Z")

</div>

Why write time related entries to an SQL database? Why not use the influxdb app to export all values to an influxdb instance? Then you dont have to create flows to export values, if a device exists, the info is exported

I do see added value in the possibility to write information to a mysql database, but for an alternative of Insights is the influx app and influxdb much better (including grafana for making dashboards, which can show info from both DB’s).

For status information between enviroments is mqtt a very good choice.

[Previous page](https://community.homey.app/t/app-pro-mysql-client/62459.md?page=1)

[Next page](https://community.homey.app/t/app-pro-mysql-client/62459.md?page=3)
