Compiling mysql-python on OS X leopard

I’ve just finished trying to install mysql-python on OSX Leopard, and had quite a few problems. This is the procedure that finally ended up working for me. First, download mysql-python from here. Unzip and try to build it : ...

August 18, 2009 · 2 min · Dave Perrett

mysql select random row with join

I have a users table and an assets (basically just images) table, and I want to select and display a random asset for each user. I want to show a list of users, with a random thumbnail for each user from their assets. I could do this easily enough in code with multiple queries, but it seemed like a nice challenge to try and find a pure-sql alternative. ...

August 11, 2009 · 2 min · Dave Perrett

InnoDB as default MySQL table type

To change the default MySQL table type, edit your my.cnf file (usually /etc/mysql/my.cnf on ubuntu), and add the following line to the [mysqld] section : default-table-type=innodb The resulting config will look something like this : ...

August 9, 2009 · 1 min · Dave Perrett

Force MySQL Encoding to UTF8

Often MySQL will need to be forced to return results in UTF8 encoding. There are two ways to do this: ...

June 23, 2008 · 1 min · Dave Perrett

MySQL Delete On Joined Tables

If you want to (for example) delete all users with the guest role from your database : DELETE FROM user WHERE EXISTS ( SELECT * FROM role WHERE role.id = user.role_id AND role.name = 'guest' );

December 2, 2007 · 1 min · Dave Perrett