mysql - Python: How to use a generator to avoid sql memory issue -
i have following method access mysql database , query executed in server don't have access change on regarding increasing memory. new generators , started read more , thought convert use generator. def getunames(self): globaluserquery = ur'''select gu_name globaluser gu_locked = 0''' global_user_list = [] try: self.gdbcursor.execute(globaluserquery) rows = self.gdbcursor.fetchall() row in rows: uname = unicode(row['gu_name'], 'utf-8') global_user_list.append(uname) return global_user_list except exception, e: traceback.print_exc() and use code follow: for user_name in getunames(): ... this error getting server side: ^gout of memory (needed 725528 bytes) traceback (most recent call last): ... packages/mysqldb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue operationalerror: (2008, 'mysql client ran out of mem...