Most (all?) SQL generation is done via the python-sql library now.
I had to extend the python-sql library a bit to do what I wanted. It's in the repo as well now.
Unit tests for the extension are there too.