add query method to check if database write fine