Updated get_counts in sql_counter to get the values from the db before closing the session