Upload history to database