Insertion to table for id and trend working

* The method write to db is working
* Added try expect block for insertion
* calling write to db from build