fr-ser / grafana-sqlite-datasource

Grafana Plugin to enable SQLite as a Datasource
Apache License 2.0
124 stars 17 forks source link

"Invalid Date" though RF3339 Formatted #59

Closed lucywinters closed 2 years ago

lucywinters commented 2 years ago

Hi Sergej,

Thanks so much for the plugin, glad that people like you are contributing to the community. I have a SQLite Database and would like to display simple info on Grafana as a graph. (am new to SQLite and Grafana) I'm running into an issue where, Grafana is telling me that the date is invalid.

The date stored in SQLite is in the following format 2021-09-19T18:20:01+10:00

I've used the following Grafana query to format the date (text) as RF3339. WITH converted AS ( SELECT E_Day, REPLACE(Timestamp, '+','Z') AS datetime FROM site WHERE Timestamp ) SELECT datetime, E_Day FROM converted ORDER BY datetime ASC

I'm fairly sure this is working as the tableview (in grafana) shows the date shows in correct format eg "2021-09-19T18:20:01Z10:00" (Screenshot from 2021-09-19 19-04-37.png)

Until / When I add "datetime" as a Time formatted column in grafana (sqlite plugin) the table shows no dates selected (Screenshot from 2021-09-19 19-05-46.png) I'm fairly sure that whatever it is causing these dates to disappear is causing my invalid date issue when I switch from Table to Graph. (Screenshot from 2021-09-19 19-04-50.png)

Is there something obvious that I've missed? Hoping you're able to point me in the right direction :-)

Kind Regards

Lucy Screenshot from 2021-09-19 19-04-46.png Screenshot from 2021-09-19 19-05-46

Screenshot from 2021-09-19 19-04-37.png Screenshot from 2021-09-19 19-05-37

Screenshot from 2021-09-19 19-04-50.png Screenshot from 2021-09-19 19-04-50

fr-ser commented 2 years ago

Why are you replacing the +? 2021-09-19T18:20:01+10:00 looks like a valid datetime to me. 2021-09-19T18:20:01Z10:00 does not look valid

lucywinters commented 2 years ago

Oh my gosh.... That has solved my datetime issue. Thank you so much. As this was not an actual issue with your plugin I'm happy for you to remove this issue (otherwise I can close)

Not specifically related to your plugin, but you may be able to assist. I have a INTEGER value in the SQLite DB which I cannot get to show on the graph. I can get the two REAL values to show.. but not the INTEGER. Sample of table below: 7|P_Grid|REAL|0||0 8|P_Load|REAL|0||0 9|P_PV|INTEGER|0||0

I suspect I need to CAST it to another datatype?

Once again, thanks so much for helping with the datetime issue.

Lucy

fr-ser commented 2 years ago

I have a INTEGER value in the SQLite DB which I cannot get to show on the graph

You should not need to cast it to show the value. Can you please open another issue and provide the query as well as some sample data so I can check it?