Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'nested': 0.07; '%s",': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'restarted': 0.09; 'dec': 0.15; 'csv': 0.16; 'match:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:compare': 0.16; 'file:': 0.22; 'seems': 0.23; 'header:X -Complaints-To:1': 0.28; 'run': 0.28; 'record': 0.28; "d'aprano": 0.29; 'steven': 0.29; "i'm": 0.29; 'code': 0.31; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'received:org': 0.36; 'but': 0.36; 'compare': 0.36; 'charset:us-ascii': 0.36; 'two': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'prices': 0.62; 'price': 0.66; 'as:': 0.75; 'basically,': 0.84; 'database:': 0.84; 'dennis': 0.91; 'received:108': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Confused compare function :) Date: Thu, 06 Dec 2012 13:41:05 -0500 Organization: > Bestiaria Support Staff < References: <50bfe9d8$0$29994$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 108.73.119.194 X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354819258 news.xs4all.nl 6844 [2001:888:2000:d::a6]:53683 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34416 On 06 Dec 2012 00:42:00 GMT, Steven D'Aprano declaimed the following in gmane.comp.python.general: > But basically, the code seems to run a pair of nested for-loops: > > for SKU in database: > for SKU in csv file: > if the two SKUs match: > compare their prices and update the database > OUCH... I'm presuming the CSV is restarted each time the database record changes... That would seem better reformulated as: for (SKU, price) in CSV: DB.execute("update SKUtable set price = %s where SKU = %s", (price, SKU) ) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/