Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'foo': 0.09; 'hits': 0.09; 'host,': 0.09; 'tuple': 0.09; 'valueerror:': 0.09; 'variables.': 0.09; 'baz': 0.16; 'cursor': 0.16; 'like?': 0.16; 'pointer,': 0.16; 'row': 0.16; 'unpack': 0.16; 'cc:addr:python-list': 0.16; 'cc:no real name:2**0': 0.20; 'charset:iso-8859-7': 0.21; 'holds': 0.21; 'header:In-Reply-To:1': 0.22; 'assumes': 0.23; 'somehow': 0.23; 'string': 0.24; 'cc:2**0': 0.24; 'hopefully': 0.24; 'code': 0.25; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'host': 0.30; "can't": 0.32; 'received:74.125.82': 0.35; 'something': 0.35; 'query': 0.37; 'but': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; 'think': 0.37; 'skip:- 40': 0.37; 'why': 0.39; 'help': 0.39; 'more': 0.61; 'order': 0.62; 'results': 0.63; 'agent': 0.65; 'imagine': 0.71; 'visitors': 0.77; 'chrome': 0.84; 'suspense,': 0.84; 'agent,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=KHjurQokNkRxEo62j+oV7Ulb5swHFW5qBXZT/CGKHj0=; b=KzqXU20WjNke8+Tb4JIWsspY/vjHyNcEPPKBrRtJIW4JAkAuKh6bAmNPV1Q2yA0HsG ErJCyFH1ZSq5QS4aMr/V8cAOPTM/8b4OJ0VRn1/x3bBbL4bXUvzMc4XAudrSYVk2wdja YNyd+c1qx9VZpKxvcQDJr73tinibEEShKBU5U= MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Mon, 9 Jan 2012 18:11:32 -0700 Subject: Re: Explanation about for To: =?ISO-8859-7?B?zenq/Ovh7/Igyu/98eHy?= Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326157923 news.xs4all.nl 6854 [2001:888:2000:d::a6]:33413 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18727 2012/1/9 =CD=E9=EA=FC=EB=E1=EF=F2 =CA=EF=FD=F1=E1=F2 : > if the MySQL query was: > > cursor.execute( '''SELECT host, hits, agent, date FROM visitors WHERE pin= =3D > %s ORDER BY date DESC''', pin ) > > can you help me imagine how the mysql database cursor that holds the quer= y > results would look like? I must somehow visualize it in order to understa= nd > it! You can think of it as a pointer, traversing over one row of the result set at a time. Hopefully this will come out legibly: ----------------------------------------------- | HOST | HITS | AGENT | DATE | ----------------------------------------------- ------------- | foo | 7 | IE6 | 1/1/11 | <---- | cursor | ----------------------------------------------- ------------- | bar | 42 | Firefox | 2/2/10 | ----------------------------------------------- | baz | 4 | Chrome | 3/3/09 | ------------------------------------------------ > Also what happend if the query was: > cursor.execute( '''SELECT host FROM visitors") ? > > the result would have to be something likelike? > > ----------------- > |somehost1| > ----------------- > |somehost2| > ----------------- > |somehost3| > ----------------- > ..................... > ..................... > |somehost n| > ----------------- > > So what values=A0host, hits, agent, date would have in 'for=A0host, hits,= agent, > date in > =A0dataset' ? Every row has one string how can that be split in 4? Why don't you try it and see what happens? But to spare you the suspense, you would get: ValueError: need more than 1 value to unpack Because you can't unpack a 1-length tuple into four variables. The code assumes that the query is selecting exactly 4 columns.