SQL statement generator in python