Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58493
| Path | csiph.com!usenet.pasdenom.info!aioe.org!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <antoon.pardon@rece.vub.ac.be> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'received:134': 0.05; 'duplicate': 0.07; 'variables': 0.07; 'data:': 0.09; 'host,': 0.09; 'iterate': 0.09; 'rows': 0.09; 'subject:into': 0.09; 'subject:string': 0.09; 'subject:How': 0.10; 'stored': 0.12; '%s,': 0.16; "'data'": 0.16; 'christ': 0.16; 'columns': 0.16; 'fetch': 0.16; 'hits': 0.16; 'iterable': 0.16; 'iterated': 0.16; 'nick': 0.16; 'subject:already': 0.16; 'typeerror:': 0.16; 'unpack': 0.16; 'skip:= 10': 0.16; 'wrote:': 0.18; 'properly': 0.19; 'stack': 0.19; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'exists': 0.24; "haven't": 0.24; 'skip:" 40': 0.26; 'this:': 0.26; 'primary': 0.26; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'record': 0.27; 'tried': 0.27; 'host': 0.29; "doesn't": 0.30; 'see,': 0.30; 'subject:list': 0.30; 'lines': 0.31; '>>>>': 0.31; 'trace': 0.31; 'file': 0.32; 'lists': 0.32; 'convert': 0.35; 'but': 0.35; 'add': 0.35; 'impression': 0.36; 'much.': 0.36; 'entry': 0.36; 'similar': 0.36; 'list': 0.37; 'easily': 0.37; 'being': 0.38; 'expected': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'new': 0.61; 'first': 0.61; 'you.': 0.62; 'here:': 0.62; 'back': 0.62; 'save': 0.62; 'act': 0.63; 'visit': 0.64; 'more': 0.64; '8bit%:92': 0.71; 'inform': 0.78; "'for'": 0.84; '(url)': 0.84; 'pardon': 0.84; 'ref': 0.84; 'respectively': 0.84; 'resulted': 0.84; 'visit,': 0.84; 'visits': 0.84; 'subject:add': 0.91 |
| X-IronPort-Anti-Spam-Filtered | true |
| X-IronPort-Anti-Spam-Result | AqEEAOvFeFKGuA9G/2dsb2JhbABagz+DW7wygT2DGQEBBSMPAUURCQIYAgIFFgsCAgkDAgECAUUTCAKHfZAIm16JJokUgSmNfToWglWBRAOYCoEvhHqLYIMn |
| Date | Tue, 05 Nov 2013 11:20:31 +0100 |
| From | Antoon Pardon <antoon.pardon@rece.vub.ac.be> |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: How to add a current string into an already existing list |
| References | <l52pdo$k0f$1@dont-email.me> <mailman.1951.1383398828.18130.python-list@python.org> <l5391q$9in$1@dont-email.me> <bdm7fiF28rrU1@mid.individual.net> <roy-D613E2.07164103112013@news.panix.com> <l58k1t$24a$1@dont-email.me> <l59842$roj$1@dont-email.me> <l5a4no$21s$1@dont-email.me> <l5a8vu$iaa$1@dont-email.me> <mailman.2041.1383639718.18130.python-list@python.org> <l5abnk$v9u$1@dont-email.me> <l5acl9$qgm$1@speranza.aioe.org> <l5ae3r$aie$1@dont-email.me> <l5afbl$ft4$1@dont-email.me> |
| In-Reply-To | <l5afbl$ft4$1@dont-email.me> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2047.1383646833.18130.python-list@python.org> (permalink) |
| Lines | 81 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1383646833 news.xs4all.nl 15927 [2001:888:2000:d::a6]:37025 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:58493 |
Show key headers only | View raw
Op 05-11-13 10:56, Nick the Gr33k schreef:
> Στις 5/11/2013 11:34 πμ, ο/η Nick the Gr33k έγραψε:
>> Στις 5/11/2013 11:10 πμ, ο/η M.F. έγραψε:
>>> On 11/05/2013 04:54 PM, Nick the Gr33k wrote:
>>>>
>>>>
>>>> ===============
>>>> data = cur.fetchall
>>> data = cur.fetchall()
>>> That is what the stack trace and Christ tried to inform you.
>>>> for row in data:
>>>> ===============
>>>>
>>>> The only thing i can understand by looking the above 2 lines is this:
>>>>
>>>> 'for' fails to iterate over 'data' because for some reason 'data'
>>>> haven't resulted as a list of rows that can be iterated row by row.
>>>>
>>>> But that just doesn't help me much.
>>>
>>
>> I see, but because of the traceback not being to express it more easily
>> i was under the impression that data wasn't what i expected it to be.
>
>
> Still similar error here:
>
> =================================
> # if first time for webpage; create new record( primary key is
> automatic, hit is defaulted ), if page exists then update record
> cur.execute('''INSERT INTO counters (url) VALUES (%s) ON
> DUPLICATE KEY UPDATE hits = hits + 1''', page )
> cID = cur.lastrowid
>
> # fetch those columns that act as lists but are stored as strings
> cur.execute('''SELECT refs, visits, downloads FROM visitors
> WHERE counterID = %s and host = %s''', (cID, host) )
> data = cur.fetchone()
>
> # unpack data into variables
> (ref, visit, download) = data
>
> # retrieve long strings and convert them into lists respectively
> refs = ref.split()
> visits = visit.split()
> downloads = download.split()
>
> # add current strings to each list respectively
> refs.append( ref )
> visits.append( visit )
> downloads.append( download )
>
> # convert lists back to longstrings
> refs = ', '.join( refs )
> visits = ', '.join( visits )
> downloads = ', '.join( downloads )
>
> # save this visit as an entry into database
> cur.execute('''INSERT INTO visitors (counterID, refs, host,
> city, useros, browser, visits, hits = hits + 1, downloads) VALUES (%s,
> %s, %s, %s, %s, %s, %s, %s, %s)''',
> (cID, refs, host, city, useros, browser, visits,
> hits, downloads) )
> ================================
>
>
> [Tue Nov 05 11:55:21 2013] [error] [client 176.92.96.218] File
> "/home/nikos/public_html/cgi-bin/metrites.py", line 268, in <module>
> [Tue Nov 05 11:55:21 2013] [error] [client 176.92.96.218] (ref,
> visit, download) = data
> [Tue Nov 05 11:55:21 2013] [error] [client 176.92.96.218] TypeError:
> 'NoneType' object is not iterable
>
>
> Now i have the parenthesis around fetchone().
> How the data cant be properly unpacked?
>
Did you read the documentation of fetchone?
--
Antoon Pardon
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-02 13:58 +0200
Re: How to add a current string into an already existing list Andreas Perstinger <andipersti@gmail.com> - 2013-11-02 14:03 +0100
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-02 18:25 +0200
Re: How to add a current string into an already existing list Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-02 16:43 +0000
Re: How to add a current string into an already existing list rusi <rustompmody@gmail.com> - 2013-11-02 10:40 -0700
Re: How to add a current string into an already existing list Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-02 18:28 +0000
Re: How to add a current string into an already existing list Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-11-02 20:30 +0200
Re: How to add a current string into an already existing list Chris Angelico <rosuav@gmail.com> - 2013-11-03 08:50 +1100
Re: How to add a current string into an already existing list Roy Smith <roy@panix.com> - 2013-11-02 18:00 -0400
Re: How to add a current string into an already existing list Chris Angelico <rosuav@gmail.com> - 2013-11-03 09:13 +1100
Re: How to add a current string into an already existing list Walter Hurry <walterhurry@lavabit.com> - 2013-11-02 21:12 +0000
Re: How to add a current string into an already existing list Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-11-03 19:06 +1300
Re: How to add a current string into an already existing list Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-03 10:56 +0100
Re: How to add a current string into an already existing list Roy Smith <roy@panix.com> - 2013-11-03 07:16 -0500
Re: How to add a current string into an already existing list Chris Angelico <rosuav@gmail.com> - 2013-11-04 00:13 +1100
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-04 19:03 +0200
Re: How to add a current string into an already existing list Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-04 22:46 +0000
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 08:54 +0200
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 10:07 +0200
Re: How to add a current string into an already existing list Chris Angelico <rosuav@gmail.com> - 2013-11-05 19:21 +1100
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 10:53 +0200
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 10:54 +0200
Re: How to add a current string into an already existing list "M.F." <morefool@gmail.com> - 2013-11-05 17:10 +0800
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 11:34 +0200
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 11:56 +0200
Re: How to add a current string into an already existing list Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-05 11:20 +0100
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 12:33 +0200
Re: How to add a current string into an already existing list Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-05 11:59 +0100
Re: How to add a current string into an already existing list Dave Angel <davea@davea.name> - 2013-11-05 05:16 -0600
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 18:20 +0200
Re: How to add a current string into an already existing list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-05 11:49 +0000
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 14:25 +0200
Re: How to add a current string into an already existing list Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-05 13:42 +0100
Re: How to add a current string into an already existing list Dave Angel <davea@davea.name> - 2013-11-05 07:15 -0600
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 17:39 +0200
Re: How to add a current string into an already existing list Tim Chase <python.list@tim.thechases.com> - 2013-11-05 09:45 -0600
Re: How to add a current string into an already existing list Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 17:50 +0200
Re: How to add a current string into an already existing list Dave Angel <davea@davea.name> - 2013-11-05 23:36 -0600
Re: How to add a current string into an already existing list Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-06 08:53 +0000
Re: How to add a current string into an already existing list Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-05 10:44 -0500
Re: How to add a current string into an already existing list Dave Angel <davea@davea.name> - 2013-11-05 05:00 -0600
Re: How to add a current string into an already existing list Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-05 17:48 +0000
Re: How to add a current string into an already existing list Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-05 11:07 +0100
Re: How to add a current string into an already existing list Larry Hudson <orgnut@yahoo.com> - 2013-11-05 20:52 -0800
Re: How to add a current string into an already existing list Chris Angelico <rosuav@gmail.com> - 2013-11-05 21:01 +1100
Re: How to add a current string into an already existing list Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-05 09:39 +0100
csiph-web