Working sql generator prototype