Στις 5/11/2013 1:16 μμ, ο/η Dave Angel έγραψε:
On Tue, 05 Nov 2013 12:33:49 +0200, Nick the Gr33k
<nikos.gr...@gmail.com> wrote:
Στις 5/11/2013 12:20 μμ, ο/η Antoon Pardon έγραψε:
> Did you read the documentation of fetchone?




fetchone is like fetchall except from the fact that the former
returned
a row of data while the latter returned a list of rows of data.

That's not the only difference. See the word None there in one of the
descriptions?

TypeError: 'NoneType' object is not iterable

Examine the statement it's complaining about. It's obvious which item
it's trying to iterate over.



--

So perhaps 'data' coudlnt retrive any values from the database that why it cannot unpack them to the 3 variables?

if so i altered the code to:

                # 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()

                ref = visit = download = []
                if cur.rowcount:
                        # 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()
                else:
                        # initiate these values
                        ref = ref
                        visit = lastvisit
                        download = ''
                
                # 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) )
=======================

but this also fail to run :( :( :(
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to