Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: INADA Naoki Newsgroups: comp.lang.python Subject: Re: Review Request of Python Code Date: Wed, 9 Mar 2016 16:52:41 +0900 Lines: 23 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de CoW7QmpsdDhaNKB6AnQ/rA6sj77Co46eNHm820A5CCug== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'cc:addr:python-list': 0.09; 'cursor': 0.09; 'url:github': 0.09; 'python': 0.10; '--\xc2\xa0': 0.16; 'fetches': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'memory': 0.17; 'email addr:gmail.com>': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'object.': 0.22; 'subject:Code': 0.22; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'message-id:@mail.gmail.com': 0.27; 'consumption': 0.29; 'convert': 0.29; 'class.': 0.30; 'saves': 0.30; "can't": 0.32; 'server': 0.34; 'received:google.com': 0.35; 'received:209.85': 0.36; '(and': 0.36; 'subject:: ': 0.37; 'client': 0.37; 'release': 0.37; 'received:209': 0.38; 'some': 0.40; 'default': 0.61; 'side': 0.62; 'url:master': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fno+lnXjXhzI+L+3JQy2WBoyt6s3DkfYUcSASOpObzI=; b=zPiV7vRD26eSqdtKqwUvolFQ29heoifuhhJrvfnHh+8nmMLy0XBC6nBINipMK/feWG zeUUSlqcH9f7rB+BVv82PqiJjr2Ux8hbCEbnX1upnt3KeXfD4jkMK4FFfSt42x8Fk8CV 1xfB7e0P6sM9eQTERi7vge+TAz9BWi2OBTYUub2e7Om2/+CbjiEC6J38pSgNdvrWwY++ PK36xIY/LRVxrCz8Ok2mJaqYnHna6M7DpDyq0FtsgbcdMajdOCYYrEiChVBwgS2FwPLN GbRHSw8D1ul6qWK+U3+DWfv66RW4YuaiExgWVJrSKNHeO5peOX46XRVt9WTJF0B30cIz w7lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fno+lnXjXhzI+L+3JQy2WBoyt6s3DkfYUcSASOpObzI=; b=fUFTrR5dp8MTkYLf9Zb4JVrwRSmJZyhZJDB/ybtYr4IOHkuZx5tvj0/NJxkmJgWsG5 UFtdj/7QqBoUMW9gvRd/hJy6AfU937YN8JYrvzWM6fMa8SF+cziRJrHnPMkxVBTqMXvM T+rd3mLH73kbhQfuJTplNWo4lfhLYd3zzSXPtCTictZ+dX5iVq/AaehgbDBDTNYhqz3R D38STC+ttpkAaqOmHdgiH+4Orbz9vUz65GQ9lZ5yj1KVL24nT+J4gYGe23k+JeoZ2ly3 IqYVl55hRP58+mPHrLxntzmC78RaI4edrNCgJOs/XA5smAthNggJ1H284WPNcZE2t+jv 0B/g== X-Gm-Message-State: AD7BkJJSe11uKE1hVPqR5sdge3ezdidKCaMtvKExRsuCQ7v7InD5zbhH+BScaJRvStEpkqGBUd+GkgerBBidyQ== X-Received: by 10.107.8.30 with SMTP id 30mr12296598ioi.60.1457509980599; Tue, 08 Mar 2016 23:53:00 -0800 (PST) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104393 While MySQL doesn't have server side cursor, MySQLdb has SSCursor class. https://github.com/PyMySQL/mysqlclient-python/blob/master/MySQLdb/cursors.py#L551 Default cursor fetches MySQL response at once and convert them into Python object. SSCursor fetches MySQL response row by row. So it saves Python memory consumption (and MySQL server can't release some resource until client fetches all rows.) To use SScursor: cur = db.cursor() > cur = db.cursor(MySQLdb.cursors.SSCursor) for row in cur.fetchall(): > for row in cur: -- INADA Naoki