fr-ser / grafana-sqlite-datasource

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

[Feature Request] Run a custom query when attaching to the database #104

Closed vsviridov closed 1 year ago

vsviridov commented 1 year ago

I have a fairly specific situation, but it could be helpful for other use-cases as well. My application database and my application logs are stored in two separate sqlite files. However when working with log data, sometimes I need to correlate entries by id to something human-readable. I'm using the feature of ATTACH DATABASE 'foobar.sqlite3' AS foobar; to then be able to run joins from the logs into the regular data.

It would be nice to have an option of running custom query when the sqlite database is attached, so I can enrich my grafana dashboard with readable names in logs where necessary.

fr-ser commented 1 year ago

Hey there.

I think running scripts at the beginning of a connection does indeed sound a bit bespoke. It would also influence session management (as in every time we open the database we need to reissue the command).

While the feature sounds reasonable I would wait and see how much demand there actually is for something like this.

vsviridov commented 1 year ago

Actually, I realized I can just add the ATTACH statement to the main query and it works. And it seems that it does not attach persistently. So it works well enough...