Added writing to the database.