v0.2 with sql generator

version with working sql generator, lot of mess, need to refractor