Refactored the resource lifecycle of database generator and added feature of generating tables