RE: Having a problem with rowcount
"Nicholas Veeser" <[email protected]>
| Newsgroups | gmane.comp.python.sybase |
|---|---|
| Message-ID | <[email protected]> |
Ok, that mostly makes sense. So why does the documentation not say that. Is that because its pulled basically from the DB-API 2.0 docs? So then what is the apropriate way to programatically determine if I got any rows back at all from a query? Basically I add the parameter which comes commandline from the user and the only way I know if its valid is if there is a row in the database. If select gives no rowcount, what should I check in its place. Or do I just catch the exception from Cursor.fetchone(). Thanx nicholas -----Original Message----- From: [email protected] [mailto:[email protected]] Sent: Sunday, April 20, 2003 3:51 AM To: Nicholas Veeser; [email protected] Subject: RE: [python-sybase] Having a problem with rowcount The rowcount is not set for selections, only for update and delete. This is a behavior of the underlying database (Sybase does it, Oracle does it, I suppose Microsoft does it too, though I don't really know). The rationale is that this way the DBMS doesn't really have to check all the possible rows until you ask to fetch them. Hope this helps, Shai. -----Original Message----- From: Nicholas Veeser [mailto:[email protected]] Sent: Saturday, April 19, 2003 00:52 To: [email protected] Subject: [python-sybase] Having a problem with rowcount So I am using FreeTDS with Python and Sybase.py. I am do a connection, cursor, execute a query and can fetch the results of the query. All that works. But when I go to change the code to check the rowcount for the status of the query, it is always -1. Should it not be set to the number of rows in the query, which for my query is like 50. Here is the code (basically): conn = Sybase.connect( cfg['dsn'], cfg['user'], cfg['pass'] ) cursor = conn.cursor() cursor.execute ("SELECT id, queuetype FROM Components") print "XXX: rowcount:", cursor.rowcount while (1): row = cursor.fetchone() if row == None: break print row connect.close() Thanx Nicholas _______________________________________________ Python-sybase mailing list [email protected] https://object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase