def fetchall(self): sleep = self.connection.sleep if sleep is _noop: return SSCursor.fetchall(self) result = [] fetch = self.fetchmany # calls _fetch_row with the arraysize while 1: # Even if self.rowcount is 0 we must still call # or we get the connection out of sync. rows = fetch() if not rows: break result.extend(rows) if self.rownumber == self.rowcount: # Avoid a useless extra trip at the end. break sleep() return result
elif fun2 in [types.IntType, types.LongType]: dtype = 'i4' elif fun2 in [types.StringType]: dtype = '|S%d'%(internal_size,) descr.append((name, dtype)) return descr database_and_table, filename = sys.argv[1:] database_name, table_name = database_and_table.split('.') connection = MySQLdb.connect(host='imgdb02', user='******', passwd=getpass.getpass(), db=database_name) cursor = SSCursor(connection) cursor.execute('select count(*) from %s' % table_name) nrows, = cursor.fetchall()[0] print nrows, 'rows' cursor.execute('SELECT * from %s' % table_name) colnames = result_names(cursor) m = Measurements(filename) object_names = set(name.split('_', 1)[0] for name in colnames if '_' in name) print 'Object names:', ', '.join(object_names) columns = [] for i, (name, dtype) in enumerate(result_dtype(cursor)): if name == 'ImageNumber':
elif fun2 in [types.StringType]: dtype = '|S%d' % (internal_size, ) descr.append((name, dtype)) return descr database_and_table, filename = sys.argv[1:] database_name, table_name = database_and_table.split('.') connection = MySQLdb.connect(host='imgdb02', user='******', passwd=getpass.getpass(), db=database_name) cursor = SSCursor(connection) cursor.execute('select count(*) from %s' % table_name) nrows, = cursor.fetchall()[0] print nrows, 'rows' cursor.execute('SELECT * from %s' % table_name) colnames = result_names(cursor) m = Measurements(filename) object_names = set(name.split('_', 1)[0] for name in colnames if '_' in name) print 'Object names:', ', '.join(object_names) columns = [] for i, (name, dtype) in enumerate(result_dtype(cursor)): if name == 'ImageNumber': image_number_index = i elif name == 'ObjectNumber': for on in object_names: