#235 sql queries (e.g. sqlite)

closed-works-for-me
nobody
None
5
2009-05-31
2009-04-11
No

Hi All,

I was trying to do an SQL query in a gnuplot script... e.g.

#!/usr/bin/env gnuplot
!sqlite3 data.db3 'SELECT x,y FROM mydata;' > data.dat
... plot commands using data.dat

But, put redirection doesn't seem to work. Would it be possible to either allow redirection or better yet, allow the input to a plot be an SQL command?

-kurt

Discussion

  • Kurt Schwehr

    Kurt Schwehr - 2009-04-11

    Well, shoot. I don't know what was up with ls, but this works just fine. It still would be great to have gnuplot talk directly to sqlite.

    #!/usr/bin/env gnuplot

    !sqlite3 classa-3station.db3 'SELECT day_number, mmsi_total, mmsi_us FROM classa_summary WHERE station="r003669930";' | tr '|' ' ' > tmp.dat

    plot 'tmp.dat' using 1:2, 'tmp.dat' using 1:3

     
  • Juergen Wieferink

    Please have a look at "help plot special-filename".

    Juergen

     
  • Nobody/Anonymous

    Juergen,

    Thanks for the suggestion. This works for me:

    splot '< sqlite3 healy.db3 "SELECT lon,lat,-depth FROM healy_summary WHERE depth IS NOT NULL;" | tr "|" " "' t 'depth'

    Would be better to be able to say something like this:

    splot 'sqlite:file:///healy.db3' using 'lon','lat',-'depth'

    But I'm definitely happier with the special-filename syntax that doesn't leave tmp files around

     
  • Ethan Merritt

    Ethan Merritt - 2009-05-31
    • status: open --> closed-works-for-me
     
  • Ethan Merritt

    Ethan Merritt - 2009-05-31

    I'm closing this, since I gather that using a piped command solves the problem.
    On the other hand, I could imagine classes of data, e.g. N-dimensional matrices, that a pipe wouldn't easily work for. If you have a real-world case that demonstrates the need, please re-open this or file another request.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks