A while back, I created a together a simple SQL parser using ply. The goal was to take SQL statements and generate their equivalent in an intermediary language. The exercise applies directly to YACC and LEX, but with the ease of Python. I have ripped out the parts that create the intermediary language, and left the rest as a tutorial on ply and SQL.
TODO