Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to figure out how to use Mathematica as a real-time interface.

I've used Excel/ODBC connection to a SQL database to use the graphing functions within to get my real-time dashboard. I also know there are many Python implementations (http://dashing.io/), Javascript (d3), Ruby() on watching data. I currently I not looking to do this at a big data implementation.

The first piece I am looking for to do is have an updated top 10 SKU Sales that are over 30 locations that are synced back to a Sql Server Database. My thought was to use a simple SQLExecute statement to the database every 5 minutes or so. Currently I am trying to figure out how to reissue that command to the db to get my new numbers and automatically update the table.

The second piece is to watch transaction flow at each of these locations. Here I just simply want to graph by the hour which I'd update an array with the data. I just don't know how to trigger the data execution.

After some searching online, I haven't found anyone who has done this with Mathematica. Does anyone have links/examples where a dashboard is implemented into Mathematica?

share|improve this question
Please give us more details regarding what you are trying to accomplish. Where is the data? What kind of metrics are you looking for? How do you want to display them? –  mfvonh Jul 17 '14 at 17:32
Is that more understandable? I've added my example in the question above. –  c.ried Jul 17 '14 at 17:58
Yep. The more specific you can be the more help people will be able to provide. You can use RunScheduledTask and its ilk to periodically query the server. You could store the results in global symbols and use Dynamic expressions for the SKU list and transaction flow graph, and they would then update each time the server is queried. Depending on what you want you could attach these to the notebook with DockedCells or create a palette. –  mfvonh Jul 17 '14 at 18:07
A bare bones version of what you want is not too difficult. But the devil is in the detail. Is this a hobby or a consulting job? A full description, beyond the tips and pointers and relevant code fragments, of how to do this is beyond the scope of this site IMO. –  Mike Honeychurch Jul 17 '14 at 22:33
I suppose I was looking for barebones which i will post tomorrow when I can answer my own question. I just needed a pointer to getting to the RunScheduledTask.. –  c.ried Jul 17 '14 at 22:37

1 Answer 1

So thanks to @mfvonb I was able to get a start building a preliminary form to create such a dashboard:

Mathematica by default needs to load the database functionality into memory (like any header file) in order to function.


Creates the connection to the database from which the data can be pulled.

conn = OpenSQLConnection["XXX"];

Following is where all the magic happens, it creates a scheduled task by which the query runs every 30 seconds to pull information which it assigns to the bass variable.

RunScheduledTask[bass = SQLExecute[conn, "  
    SELECT DATEPART( HOUR,CAST(a.Invoice_Date as time)),  
SUM(b.Price_As_Sold_QTY_Total) as NetSales
     FROM Invoice_Header as a INNER JOIN Invoice_Detail 
as b ON a.Invoice_Header_ID = b.POS_Invoice_Header_ID
     INNER JOIN Inventory as c ON b.SKU_ID = c.SKU_ID 
     INNER JOIN Deals as d ON c.Deal_ID = d.Deal_ID
     WHERE a.Invoice_Date >= CAST(GETDATE() as date) 
     GROUP BY DATEPART( HOUR,CAST(a.Date as time))
    "], 30];

And lastly, a list plot will continually update as new data has been pulled.

Dynamic[ListPlot[bass, PlotTheme -> "Scientific", Filling -> Axis,
Joined -> True, PlotLabel -> "Day Sales (updated 30 sec)"]]

And that is it, it will continue to update the graph in real-time.

a simple output

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.