From: Nicholas V. <nic...@pl...> - 2003-04-22 11:14:06
|
Ok, that mostly makes sense. So why does the documentation not say that. Is that because=20 its pulled basically from the DB-API 2.0 docs? So then what is the apropriate way to programatically=20 determine if I got any rows back at all from a query? Basically I add the parameter which comes commandline from the=20 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=20 Cursor.fetchone(). Thanx nicholas -----Original Message----- From: Sha...@in... [mailto:Sha...@in...] Sent: Sunday, April 20, 2003 3:51 AM To: Nicholas Veeser; pyt...@ob... 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:nic...@pl...]=20 Sent: Saturday, April 19, 2003 00:52 To: pyt...@ob... 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,=20 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 =3D Sybase.connect( cfg['dsn'], cfg['user'], cfg['pass'] ) cursor =3D conn.cursor() cursor.execute ("SELECT id, queuetype FROM Components") print "XXX: rowcount:", cursor.rowcount while (1): row =3D cursor.fetchone() if row =3D=3D None: break print row connect.close() Thanx Nicholas _______________________________________________ Python-sybase mailing list Pyt...@ob... https://object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase |