Στις 5/11/2013 11:34 πμ, ο/η Nick the Gr33k ÎγÏαψε:
Στις 5/11/2013 11:10 πμ, ο/η M.F. ÎγÏαψε:
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?