Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18727
| 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 | <ian.g.kelly@gmail.com> |
| 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 | <CAGeFqcC=hc5xMgwqLAbdMR=cCdjYVhAbQvS9yeaxMH=o766_mA@mail.gmail.com> |
| References | <e1a94d90-57b4-4f6c-be9a-bef08f978639@h13g2000vbn.googlegroups.com> <CALwzidmkSPAQBUxHTUWdoj+QKTR91UO_EPoMxr+2G+Qcy4PZdw@mail.gmail.com> <CAGeFqcC=hc5xMgwqLAbdMR=cCdjYVhAbQvS9yeaxMH=o766_mA@mail.gmail.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 9 Jan 2012 18:11:32 -0700 |
| Subject | Re: Explanation about for |
| To | Νικόλαος Κούρας <nikos.kouras@gmail.com> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4567.1326157923.27778.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
2012/1/9 Νικόλαος Κούρας <nikos.kouras@gmail.com>: > if the MySQL query was: > > cursor.execute( '''SELECT host, hits, agent, date FROM visitors WHERE pin = > %s ORDER BY date DESC''', pin ) > > can you help me imagine how the mysql database cursor that holds the query > results would look like? I must somehow visualize it in order to understand > 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 host, hits, agent, date would have in 'for host, hits, agent, > date in > dataset' ? 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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Explanation about for Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-09 15:23 -0800
Re: Explanation about for Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-09 16:42 -0700
Re: Explanation about for Chris Rebert <clp2@rebertia.com> - 2012-01-09 15:58 -0800
Re: Explanation about for Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-09 18:11 -0700
Re: Explanation about for Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-10 01:02 -0800
Re: Explanation about for Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-01-10 11:57 +0100
Re: Explanation about for Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-10 03:38 -0800
Re: Explanation about for Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-01-10 14:52 +0200
Re: Explanation about for Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-10 03:37 -0800
Re: Explanation about for "Frank Millman" <frank@chagford.com> - 2012-01-10 15:39 +0200
Re: Explanation about for Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-01-10 16:22 +0100
Re: Explanation about for RainyDay <andrei.avk@gmail.com> - 2012-01-11 14:39 -0800
Re: Explanation about for Nick Dokos <nicholas.dokos@hp.com> - 2012-01-10 10:24 -0500
Re: Explanation about for Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-11 14:50 -0800
csiph-web