Skip to main content


Showing posts from August, 2012

Dell Sputnik Ultrabook: Initial Impressions

I got word a couple of days ago that I got into the Dell "Sputnik" beta program, which is Dell's incubation project to bring a GNU/Linux-based (specifically Ubuntu-based) XPS 13 Ultrabook to market as a product, specifically as a machine aimed at developers. (We developers, lone wolves though we tend to be, do like a little attention now and then!)
As a huge free software and Linux proponent I have been watching this project closely so I was really excited to get an invite to the beta, and I received the machine today. General Disclaimer: The machine was not free. Dell did offer a discount for beta program participants but is heavily encouraging everyone to be very transparent and honest with their impressions of the machine.
In another blog post I'll cover how I went about installing Ubuntu and the Sputnik-specific PPAs, but in this post I'll share my initial impressions of the machine. (tl;dr version: With one minor exception, this is an absolutely beautiful, e…

Installing MySQL Python Module on Ubuntu

After tearing through several other Django books and tutorials using sqlite3 as the database, I'm starting to go through the book Beginning Django E-Commerce and it uses MySQL as the database. I use MySQL quite a lot so that side of things isn't an issue, but I did run into a couple of wrinkles getting MySQL and Django playing nice so I thought I'd share.
Basically if after configuring your database in and running python dbshell you get a bunch of errors, you have a minor amount of installation work to do to get things rolling.
First thing I did was install pip, which is a better version of/replacement for easy_install: sudo easy_install pip
Next I ran pip upgrade for good measure (probably not necessary but can't hurt, and worth running if you already had pip installed): sudo pip install pip --upgrade
On my machine (Ubuntu 12.04 64-bit) I also had to build the dependencies for the python-mysqldb libraries: sudo apt-get build-dep python-mysqldb
And f…

Manually Installing the Django Plugin for Eric

If you install Eric (specifically Eric 4) from the Ubuntu software repos, the Eric plugin repository points to a location that's unavailable:

I'm sure there's a way to change it but I don't see how to do it in the app itself (haven't started poking around to see if there are config files somewhere yet), but luckily Eric plugins are just zip files so you can download them from a repository URL that works, and then add them to Eric.

The working plugin repository is here:

From there just do a ctrl-F to find the plugin you're looking for, then copy/paste the URL for the plugin's zip file into your browser (or use wget or whatever floats your boat) to download the plugin.

With the zip file downloaded, in Eric go to Plugins -> Install Plugins, click Add, and then point to the zip file you downloaded.

If someone knows how to change the plugi…

Connecting to SQL Server with pyodbc

At long last after my previous posts on this topic we get to the easy part: using pyodbc to run queries against SQL Server.

If you need to get caught up, the posts you'll want to go through before proceeding with this one are:

Installing pyodbc on UbuntuFreeTDS Quick StartCreating a Datasource with FreeTDS and unixODBC With a datasource created in unixODBC this last part is rather anti-climactic, but this is of course also where you can get some real work done in Python.
First, in a Python console ('python' from a terminal or whatever your favorite Python console tool is), import pyodbc: >>> import pyodbc
Next, create a connection to the datasource using the datasource name, which in this case we'll assume is foo: >>> conn = pyodbc.connect('DSN=foo;UID=username;PWD=password')
If you don't get any errors, the connection was successful. Next, create a cursor on that connection: >>> cursor = conn.cursor()
Now we can execute a query again…

Creating a Datasource with FreeTDS and unixODBC

In a couple of previousposts I've been working up to using Python to talk to SQL Server from Linux. There are a few moving parts involved so I'm documenting as I go.

Thus far I've done the following: Installed unixODBCInstalled FreeTDSInstalled pyodbcInstalled pymssql Note that pyodbc and pymssql accomplish the same thing in slightly different ways, and I'll document both as I get those set up.
To put the first two items above in perspective, unixODBC provides the underpinnings for the ODBC API on Unix/Linux platforms. unixODBC does not, however, provide what you need to talk to specific databases. For that you need ODBC drivers for each database with which you wish to communicate, which is where FreeTDS comes in.
FreeTDS is an implementation of the Tabular Data Stream protocol, which is the protocol used by SQL Server (and Sybase), and FreeTDS includes ODBC libraries that you can install in unixODBC. So when you put these two pieces together, you can talk to SQL Server…

FreeTDS Quick Start

This is the first of a couple of follow-ups to my last post which covered how to install pyodbc on Ubuntu. The ultimate goal here is to be able to use Python (my new development weapon of choice) to communicate with SQL Server from GNU/Linux (specifically Ubuntu).

Part of this equation is to install FreeTDS, which is a set of C libraries that facilitate talking to SQL Server from Linux. I'm still wading through both pyodbc and pymssql but from what I can tell thus far both these solutions use (or can use) FreeTDS. (Random aside: if you're familiar with jTDS that's a Java implementation of FreeTDS. And another fun fact, TDS stands for "Tabular Data Stream," which is the protocol used by the native SQL Server client from Microsoft.)

Installing and using FreeTDS is simple enough but I figured I'd take notes for my own reference and share in case they help anyone else wanting to set this up.
Installation If you're familiar with compiling and installing things…

Installing pyodbc on Ubuntu

If like me you have to begrudgingly talk to SQL Server on occasion, but you want to do so from Python on Ubuntu, you're in luck. As I'm finding is true with most things in the Python world there's a module to suit your needs.

Where SQL Server is concerned there are actually two modules available, pyodbc and pymssql, and I'm going to try both of these out to compare and contrast. In theory pymssql should be faster since it doesn't use ODBC, but pyodbc seemed as good a place as any to start.

Installation is simple enough in theory -- download the source zip and run:
python build install

On Ubuntu, however, you may run into an error or two due to missing libraries. Thankfully this is also quite easy to fix.

The specific error I ran into was:
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]

The fix is to install the unixodbc libraries as well as the python-dev libraries:
sudo apt-get install …

Pidgin, SIPE, and Read Error on Ubutnu 12.04

I think I may have posted about this before but I couldn't find it, so since I was doing a clean install of Ubuntu 12.04 on one of my laptops this weekend I figured I'd write it up again.

If you're on Ubuntu 12.04, you use Pidgin (which you should -- Empathy sucks), and you need to connect to MS Lync (formerly known as Office Communicator), thankfully you can simply install the SIPE plugin for Pidgin:
sudo apt-get install pidgin-sipe

In my case I also had to specify this as the User Agent to get it to connect:
UCCAPI/4.0.7577.314 OC/4.0.7577.314 (Microsoft Lync 2010)

There's one additional wrinkle on Ubuntu 12.04, because even after installing the SIPE plugin and setting the user agent, you may see "Read error" when you try to connect.

You're never alone on the Internet -- other people have run into this too, and the solution is simple enough, but since I didn't want to have to do that every time I launched Pidgin I put that in a bash script and changed…

Notes on Practical Django Projects (Part 1)

I'm currently making my way through Practical Django Projects by James Bennett and thought I'd share some notes and errata as I go along. (Side note: If you want a paper copy of this book, it's dirt cheap at; just make sure to get the second edition which was published in 2008).

I've done a small amount with Python here and there in the past (writing some scripts to handle very specific tasks or that used libraries available in Python that were better than what's available in Java) and always really liked the language, but I haven't ever looked into building webapps with Python until now.

So far I'm quite impressed. Having worked with Grails a little in the not-too-distant past I'm finding Django to be similar conceptually but a little simpler, and it seems to be extremely well thought-out and strike an excellent balance between forcing a convention on the developer and requiring just enough to configuration to maintain a lot of flexibility…