As promised, here is short example of the Daemon in operation.
First, in order to generate some data for us to work with, I did the following:
This nice page shows us how to get various stock data from Yahoo, who are kind enough to provide an easy-to-access API to their data, and even retrieve it as a CSV file.
The URL I used in this example is: http://quote.yahoo.com/d/quotes.csv?s=MSFT+GOOG+DENN&f=sb2b3c6
It gives us the symbol name, real time ask value, real time bid value, and real time change in percent.
Obviously most cases will include much more data than this, however this should suffice for this example. I wasn’t even creative enough to select different companies than the example given by the website, so we have data for Microsoft, Google and Denny’s.
As we remember the case is that the MySQL table gets updated on a constant basis in the backend, so we have an illustrious Linux daemon to dump the data from the MySQL server to a static file, for web users to read one way or another.
For your convenience, here is the complete database dumped from my computer in SQL (for the sake of testing the daemon).
Once loaded, as we remember the in previous post, we set the connection string in config.py and proceed to running the Daemon.
What we should get from a MySQL table that looks like this:

If we have select the PHP mode, we will get a file which will look like this:
If we select the XML method, we should get this file every X seconds (according to our setting in the config):
<quotes>
<symbol id="MSFT">
<ask>
31
</ask>
<bid>
31
</bid>
<change>
+0.208
</change>
</symbol>
<symbol id="GOOG">
<ask>
603
</ask>
<bid>
602
</bid>
<change>
+7.92
</change>
</symbol>
<symbol id="DENN">
<ask>
3
</ask>
<bid>
2
</bid>
<change>
+0.03
</change>
</symbol>
</quotes>
That’s It!
P.S.
While preparing this example, I found a few bugs in the code:
First of all if it doesn’t run at all, complaining about not finding some attribute in the ‘config’ module, this is the ‘dbpasswd’ section fault – you can safely comment that out, and not use that whole apparatus, as it includes some cyclic imports, and is just a redundant hack.
Just put the DB password in the config file.
Also, the file output config and usage in methods.py does not follow the same convention as the rest of the places where I set paths and filenames. There the path needs to end with a ‘/’ because later there is none defined, as opposed to the log output for instance, where I define the path + filename with a ‘/’ between them.
If this bothers you – fix it!
P.P.S.
In addition, while writing this, and discovering the Yahoo service I used above, and as pointed out by my good friend Amir, it might be an interesting idea to just refer your web applet to Yahoo’s web service, and have your AJAX hammer their servers instead of yours – they can probably handle the traffic…
Obviously this is only a solution for stock related applications, but keep in mind that this whole thing was designed for a very specific need, under very specific limitations, but I am posting about it here, and hopefully have created the script in such a manner, so as to answer perhaps a broader spectrum of needs.
Have Fun.
Tom.