“MySQL server has gone away”

I have written a few Twisted scripts at work that parse incoming data from a socket and save it in a MySQL database, using the MySQLdb package. It’s a well-known fact that the MySQL server will close connections that are inactive for some time and yet I forgot to handle it in last script I wrote. Previously I solved the problem by remembering the last time I used the connection and forcing a reconnect based on this value or the recycle option in SQLAlchemy’s connection pool when I needed a connection pool (which does basically the same as the former). But when I found the problem in the latest script today, I thought I should finally solved it properly, so I started Googling…

TagLib 1.6.1

TagLib 1.6.1 has been released. It’s a minor bug-fix release. Main changes are content-based detection of .oga files, saving Vorbis Comments to Ogg FLAC files and support for cover art in MP4 files. Tarball is available here for now, later also on Scott’s page, and updated API docs are here.

Working with branches in Bazaar

Many people dislike the directory-per-branch concept that Bazaar uses. What they don’t realize though, is that this doesn’t mean you need to have a working tree for each branch. You can very easily simulate cheap Git-style branches, but with some added flexibility. Checkouts are a fairly well known feature of Bazaar, but people mostly associate it with the centralized workflow (i.e. checking out remote branches). This is not the only use case for them.

UUID generator in PL/pgSQL

While writing an SQL script to upgrade the MusicBrainz database for the last release, I needed a way to generate new UUIDs from SQL. PostgreSQL has a native UUID data type and a contrib module for generating UUIDs since version 8.3, but this wouldn’t help me, because I needed it to work with at least version 8.1. I had this idea to write PL/pgSQL functions to generate UUIDs, so I skimmer over the RFC 4122 that documents them and found out that it isn’t actually that hard.