Στις 5/11/2013 1:49 μμ, ο/η Steven D'Aprano έγραψε:
On Tue, 05 Nov 2013 12:33:49 +0200, Nick the Gr33k 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.

Read the documentation of fetchone again:

http://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.fetchone

Take careful note of what it does when there is no more data to fetch.



I dont know why it copmains about:
TypeError: 'NoneType' object is not iterable

what object is supposed to have benn of None type? how do i check for
it?

Does the name "NoneType" give you a hint? Repeat after me:

"The type of **** is NoneType."

Take a guess what the **** should be. Then test it, in the interactive
interpreter:

type(****)  # replace the stars with the object


and see what is printed.





# 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()
                
print( type(data) )
sys.exit(0)

i tried inserting a type function to notify me of the datatype of 'data' but that didnt help too.

Still:
[Tue Nov 05 14:22:32 2013] [error] [client 176.92.96.218] File "/home/nikos/public_html/cgi-bin/metrites.py", line 268, in <module> [Tue Nov 05 14:22:32 2013] [error] [client 176.92.96.218] (ref, visit, download) = data [Tue Nov 05 14:22:32 2013] [error] [client 176.92.96.218] TypeError: 'NoneType' object is not iterable

Unfortunately i still miss your point.

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to