Building MySQL universal binaries using MacOS X 10.6 (Snow Leopard)

On the eve of 2010.. and your boss wants to stick to these MacOS X 10.5 machines, too stubborn or chicken to upgrade. Some developers still have their old PowerBook laptops and they need MySQL flying on PowerPC machines. To top it all, one guy said he wanted to have 32 and 64-bit in one bite. Sigh .. But there is an easy way out! A universal binary! This post shows you a way to create MySQL universal binaries using MacOS X 10.

A chessboard in MySQL: make your moves

Playing chess within MySQL? Over the network? In the .. cloud? Yes! This is a follow-up post of my ‘A chessboard in MySQL’ where we create and populate a chessboard. But pieces need to move, and a few wondered how. Easy! As an example, white openes with 1.e4: BEGIN; UPDATE chessboard SET e='♙' WHERE x = 4; UPDATE chessboard SET e='' WHERE x = 2; COMMIT; Pretty obvious. Now lets put it in a stored procedure (source included in post) so the next move is easier on the fingers and more fun to play.

A chessboard in MySQL

Something to keep you warm during cold winter nights, or cool during hot summer days: a chessboard in MySQL! Note: You should see chess pieces here below. If not, you’re not watching it using UTF-8, or get yourself a good browser! CREATE TABLE `chessboard` ( `x` tinyint unsigned NOT NULL, `a` enum('','♔','♕','♖','♗','♘','♙','♚','♛','♜','♝','♞','♟'), `b` enum('','♔','♕','♖','♗','♘','♙','♚','♛','♜','♝','♞','♟'), `c` enum('','♔','♕','♖','♗','♘','♙','♚','♛','♜','♝','♞','♟'), `d` enum('','♔','♕','♖','♗','♘','♙','♚','♛','♜','♝','♞','♟'), `e` enum('','♔','♕','♖','♗','♘','♙','♚','♛','♜','♝','♞','♟'), `f` enum('','♔','♕','♖','♗','♘','♙','♚','♛','♜','♝','♞','♟'), `g` enum('','♔','♕','♖','♗','♘','♙','♚','♛','♜','♝','♞','♟'), `h` enum('','♔','♕','♖','♗','♘','♙','♚','♛','♜','♝','♞','♟') ) DEFAULT CHARSET=utf8; Populating it with Python using MySQL Connector/Python (only piece of script shown):

Using character sets with MySQL Connector/Python

Here is two small examples showing the wonderful world of character sets and unicode using MySQL Connector/Python (using 0.1.2-devel and up) in both Python v2.x and v3.1. The following table will be used with default character set latin7, i.e. [ISO-8859-13](http://en.wikipedia.org/wiki/ISO/IEC_8859-13). Just setting it to [UTF-8](http://en.wikipedia.org/wiki/UTF-8) would be bit boring! CREATE TABLE `latin7test` ( `c1` varchar(60) DEFAULT NULL ) DEFAULT CHARSET=latin7 Things to note for the code listed below are:

MySQL Connector/Python 0.1.2-devel available!

MySQL Connector/Python 0.1.2-devel is a quick follow-up release for 0.1.1 fixing a few problems around character sets and unicode. You can download Connector/Python from LaunchPad. Release notes for MySQL Connector/Python 0.1.2-devel: o Fixing unicode usage for both Python 2.4+ and 3.1 * Setting 'use_unicode' at connection time is now working. * conversion.py: removing regular expression for quoting backslashes. * Adding test case for bug lp:499410 o Py3k specific: * Strings from MySQL are decoded to the given character when use_unicode is false * The statement is encoded just before sending it to the MySQL server.