[Kst] Database table/query "file" format support

Nicolas Brisset nicolas.brisset at free.fr
Sat Jul 21 17:36:22 UTC 2012


Hi,

> Would it be possible to add database table and/or SQL query as a
> "file"
> format that could be used in Kst?  I would like to graph data
> directly from
> a MySQL database.
Yes! In fact, I am surprised this has not been requested before. But if you look at the Kst roadmap page (linked from kst-plot.kde.org) you will see that this is part of the ideas.
I recently documented quite in detail the steps involved in adding support for a new format. You can find the file here: http://websvn.kde.org/*checkout*/branches/work/kst/portto4/kst/src/datasources/HOWTO_add_a_datasource.txt?revision=1283503
Basically, what you need is to be able to recognize that the file format is supported by your datasource, then to list available variables (strings, scalars, vectors and matrices, vectors being the most common and all actually being optional). Then you need to be able to count the number of samples available for each vector variable. Finally, you need to provide the data values as doubles upon request from Kst. There is also the possibility of adding metadata attached to the datasource or each variable, but this can be added in a later step.

If you have some programming knowledge, it would be great to give it a try. With QtSql it should be fairly straightforward. One thing that is not documented is how to create a config dialog, which we may need in that case. Unless we agree on an ASCII file format to use as metafile (since a DB has no filesytem image), so that we can continue using the data wizard. I'd go for the second option, concretely a file containing something like:

Database connect info: DB name, host, port, user, password
Vector list query: [SQL query]
Count samples query: [SQL query]
Retrieve data query: [SQL query]

This should be enough for a start. Other types and metadata can be added later. 
You will probably need to use placeholders in your query, like #Variable# (only a suggestion), which Kst would then substitute with the variable name before requesting from the database.

I don't know if you are a programmer or know someone who could give it a try. For someone with good Qt experience I think a few hours should be enough for a first proof of concept. And probably a few days to have something polished...

I personnally won't have time in the next weeks to really work on that, but I'd be glad to support since I think this is a pretty cool idea.

Cheers,

Nicolas 


More information about the Kst mailing list