Only open the database once.