Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58493
| Date | 2013-11-05 11:20 +0100 |
|---|---|
| From | Antoon Pardon <antoon.pardon@rece.vub.ac.be> |
| Subject | Re: How to add a current string into an already existing list |
| References | (9 earlier) <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2047.1383646833.18130.python-list@python.org> (permalink) |
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