dtrace is a sun developed (apple ported) technology for telling you what your computer is doing. I would try to explain it further but I would be doing it a great injustice. I first started learning about it here (http://www.youtube.com/watch?v=6chLw2aodYQ). Towards the end of the video Mr. Cantrill goes over using dtrace with python. One previous attempt at making this work on Leopard did not go over so well (but I did not put forth a lot of effort either) but giving it another try on Snow Leopard it seems to work just fine out of the box.

I downloaded the dtrace toolkit which has a lot of dtrace scripts. After unpacking it and navigating to the python directory I simply ran the following (at the command line).

sudo dtrace -s nameofscript.d’

I tried a bunch of the scripts provided in the tool kit and they work beautifully, providing an interesting look into what your python vm is up to.

Sphinx is an excellent way of maintaining documentation, especially as it relates to programming, in particular python. I am a fan of the code highlighting and multiple output formats. I like using the html generation for day to day use but for the times I need more official looking documentation the pdf generation is excellent (if not a bit persnickety).

Installing sphinx is simple (easy_install sphinx) but it does not generate pdf’s out of the box, just latex. You can download latex for the mac from http://www.tug.org/mactex/. It is also not to difficult to install as it comes with an installer with the usual ./configure, make, sudo make install incantation.

Once all is installed you can start a sphinx documentation project from the command line with sphinx-quickstart. Adding and editing content is best described at Sphinx’s own website.

If you chose correctly in the setup you can now build documentation with a simple make command. Building pdf’s is a two step process where you ‘make latex’ and then go into the latex build directory where you ‘make all-pdf’. When all is said and done you should have a very presentable pdf file inside the latex build directory.

Like I mentioned before, I have found the pdf generation to be very sensitive to errors in your source files but they are “usually” easy to find and fix.

I develop on a mac but have to connect to mssql at some point or another. I had heard of freetds but I ended up taking the commercial way out with Actual Technologies mssql odbc driver for the mac because I wanted something that ‘just worked’ and it seemed reasonably priced. I have made do with that for over a year now.

My Snow Leopard upgrade rendered the Actual Technologies driver unusable with pyodbc and I am not overly sure why, something to do with 64bit even though I am not running the 64bit kernel. The driver itself would still talk to the database with it’s bundled ‘test connection’ but once coupled with pyodbc the house of cards came down. The support email request I sent out went unanswered so I started exploring alternatives while waiting.

I downloaded the latest freetds stable package from freetds.org. After snooping around online for a little while I found the configure script incantation that makes everything work (for me at least, your mileage may vary).

./configure –prefix=/usr/local/freetds –with-iodbc=/usr –with-tdsver=8.0
make
sudo make install

Specifying the tds version turned out to be the kicker for me to get it to work with pyodbc, without that freetds worked (tested using the bundled fisql tool) but did not work with pyodbc (not unlike Actual Technologies at this point). It seemed to ignore all tds version specification in the freetds.conf file (and I tried many from sources who swore they had a working installation). I found a random comment on sqlalchemy boards attesting to the same. I tried it out of desperation thinking that could not possibly work (that is why the conf file exists after all) but low and behold angels sung and my snow cat and python could finally talk to the evil empire database once again. One other thing I should note, I used the latest build of pyodbc available off github to test all this.

Snow Leopard does not for some odd reason come with the ODBC Administrator app that has accompanied previous versions of the 10.x series. It has been provided as a separate download by Apple. To finish the configuration I downloaded this app and went to the ‘Driver’ section and filled it out as depicted in the screen shot. One could optionally just create the correct config files in the correct locations and get the same result. I was unaware of all the correct locations and such until I found another web page detailing it so this was easier for me at the time.

FreeTDS Driver Config

FreeTDS Driver Config

With all this upgrading I decided to test out the two issues I filed about pyodbc and added comments to both. In summary, I would say both issues are resolved but I still am a bit confused about why unicode query strings do not seem to work.
- http://code.google.com/p/pyodbc/issues/detail?id=29
- http://code.google.com/p/pyodbc/issues/detail?id=46

Other resources:
- (wish I found this first) http://lists.ibiblio.org/pipermail/freetds/2009q2/024684.html
- http://cubist.cs.washington.edu/doc/FreeTDS/userguide/x1853.htm
- http://stackoverflow.com/questions/947077/using-pyodbc-on-linux-to-insert-unicode-or-utf-8-chars-in-a-nvarchar-mssql-field
- http://stackoverflow.com/questions/539430/connecting-to-ms-sql-server-using-python-on-linux-with-windows-credentials