db.commit() only once per block