On 22/11/13 22:08, Paul Steele wrote:
I am getting a numrows count of -1 when I print numrows (see line 23 of
the code). What does "-1" mean? I think my connection is working
and my table has data.
I don't know about MySQL but the sqlite3 module documentation says:
-------
As required by the Python DB API Spec, the rowcount attribute “is -1 in
case no executeXX() has been performed on the cursor or the rowcount of
the last operation is not determinable by the interface”. This includes
SELECT statements because we cannot determine the number of rows a query
produced until all rows were fetched.
--------
That may help but you should check the docs for the mysql module for
details of that implementation.
Also I notice something odd in your code:
cur.execute("select Name from Rosters")
numrows = cur.rowcount
print numrows
for x in xrange(0,numrows):
row = cursor.fetchone() #AG - You never use row?
print "Name" #AG - just prints the literal string
You do realize that this will not print the names retrieved? It will
print the literal string "Name" once for each row found. I suspect
that's not what you want?
Check the examples on the sqlite3 module page for examples
(in sqlite) of how to do what (I think) you want.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor