add logic to write sqlite database