Strange behavior of MySQL SELECT
I have some problem with the following script: it has to select some records from a table and then process it.

When the variable **NUMBER_OF_ITERATIONS** is set to 1, everything works fine...but when I change it to any value greater than 1 I get some problems.

First of all, in this case when i print the value of **res** i get an huge number (like 18446744073709551615) that I suppose cames from an overflow.

Second, but most important, in this case the script can't process data because the lenght of value is always 0...





    if __name__ == '__main__':

        NUMBER_OF_ITERATIONS = 2
        
        conn = DBconnection()	# return a database connection
    
        for i in range( NUMBER_OF_ITERATIONS ):
            cursor = conn.cursor()
            res = cursor.execute( 'SELECT field FROM table WHERE other_field = 0 LIMIT 10 LOCK IN SHARE MODE' )
            print '# of selected rows: ' + str(res)
			
            values = []
            for elem in cursor.fetchall():
                if elem != None:
            	    values.append( list(elem).pop() )
                
            if len( values ) != 0:
                # do something...
            
            else:
                print 'NO VALUES AVAILABLE'
                cursor.close()
                break
    
        conn.close()
        print 'DONE'


What's the difference from one to 2 (or more) iterations? I can't get the point.
(I'm using the InnoDB storage engine)

Thank you
Strange behavior of MySQL SELECT
===

I have some problem with the following script: it has to select some records from a table and then process it.

When the variable **NUMBER_OF_ITERATIONS** is set to 1, everything works fine...but when I change it to any value greater than 1 I get some problems.

First of all, in this case when i print the value of **res** i get an huge number (like 18446744073709551615) that I suppose cames from an overflow.

Second, but most important, in this case the script can't process data because the lenght of value is always 0...





    if __name__ == '__main__':

        NUMBER_OF_ITERATIONS = 2
        
        conn = DBconnection()	# return a database connection
    
        for i in range( NUMBER_OF_ITERATIONS ):
            cursor = conn.cursor()
            res = cursor.execute( 'SELECT field FROM table WHERE other_field = 0 LIMIT 10 LOCK IN SHARE MODE' )
            print '# of selected rows: ' + str(res)
			
            values = []
            for elem in cursor.fetchall():
                if elem != None:
            	    values.append( list(elem).pop() )
                
            if len( values ) != 0:
                # do something...
            
            else:
                print 'NO VALUES AVAILABLE'
                cursor.close()
                break
    
        conn.close()
        print 'DONE'


What's the difference from one to 2 (or more) iterations? I can't get the point.
(I'm using the InnoDB storage engine)

Thank you