I highly recommend pypika by Kayak:
https://github.com/kayak/pypikaHave used in multiple projects and have found it's the right balance between ORMs and writing raw SQL. It's also easily extensible and takes care of the many edge cases and nuances of rolling your own SQL generator.