Revivification18 Mar 2012
Hello Blog. Welcome to 2012.
So world. How have you been? Me? I’ve been out of touch.
You see… things got pretty hectic there for a while finishing up my latest video game. Granted it shipped over a month ago and I have had a little vacation since then, but it seems to take longer and longer as I get older to recover from the finaling push. That isn’t to say that I am enjoying it any less, it just takes a little longer to recover.
Lately I have been on sort of a digital walkabout. Poking around the programming world to see what is new, interesting and different. In search of the ever elusive wind that rekindles the embers of programming passion.
A word of warning: this entry is going to contain lots and lots of links to additional information for those who aren’t familiar with everything I’m going to talk about.
One thing that I have been playing with is CouchDB. CouchDB is one of the new generation of NoSQL databases. Which is just another way of saying a non-relational databases. A relational database stores everything in terms of tables of relations, where a relation is defined as a list of tuples (ordered lists of elements); and a table is a list of relations where each relation always has the same number of elements.
That sentence sort of got away from me there.
CouchDB on the other hand stores everything as documents. Every database entry can have as much or as little data stored in any type of hierarchy that it wants. This is incredibly flexible and powerful!
This means you can have lists, dictionaries (key/value pairs), all kinds of data structures packed away in there; all mashed around in any form you want to suit your needs. You can even reference other documents just like you would other tables in a traditional relational database.
I had been following CouchDB from the sidelines for a while and decided to dive in and try it out. I didn’t want to bother hosting my own database to get started with so I headed over to IrisCouch to sign up for a free hosted CouchDB database (is database redundant there? Probably).
I decided to write a little application that could take a list of TV episodes and track what I have and haven’t watched yet. I like TV, but now that I watch it on cable, DVD, Blu-ray, Hulu, Netflix and other sites. It gets hard to keep track of things. Especially when one show pulls you away from everything else for a while; say a month or a year. You can easily forget where you left off (I’m looking at you Grey’s Anatomy!)
So I picked my language of choice and got to work. For those who are curious, I picked Python. Why did I pick Python? Because Python is full of AWESOME! If you want to get something knocked out quickly, it is to me the best way to go.
I put together a list of all of the shows, seasons, and episodes that I cared about as a test. Then I wrote a quick script in Python to create ‘Show’ documents. Each ‘Show’ holds its ‘Season’s, which hold their ‘Episode’s. I used the excellent couchdb-python to do the heavy lifting of connecting to the remote CouchDB, creating the database and uploading the documents. The entire script was less than 100 lines of code, and I use a lot of blank lines. I guess I just like negative space.
You can even edit your queries in real time with temporary views.
The end result? In a few hours I had thrown together a really simple, and ugly, site that met all of my needs. Want to see? Here is my quick little tvdb. Obviously it still needs some love and attention. Will it ever get it? Who knows?
I had a lot of fun with my little side project! I learned a lot and now have crazy ideas for things I could do with this type of database!
Well, if anyone is still here, I’ll try not to make all of my entries quite so tech heavy.