Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.057 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'processing.': 0.07; 'url:peps': 0.09; 'python': 0.11; 'cursor': 0.16; 'optional': 0.16; 'received:80.91': 0.16; 'received:80.91.229': 0.16; 'received:gmane.org': 0.16; 'received:list': 0.16; 'row': 0.16; 'sqlite3': 0.16; 'mon,': 0.18; 'versions': 0.18; 'function': 0.22; 'appears': 0.22; 'index': 0.22; 'unknown': 0.22; 'url:dev': 0.22; 'url:home': 0.22; 'this?': 0.24; '(the': 0.26; 'obviously': 0.27; 'interface': 0.28; 'worked': 0.28; "i've": 0.28; 'fetch': 0.29; 'surprised': 0.29; 'anyone': 0.30; 'con': 0.33; 'url:python': 0.34; 'server': 0.34; 'two': 0.35; 'sql': 0.35; 'received:76': 0.35; 'header:X-Complaints-To:1': 0.36; 'url:org': 0.36; 'does': 0.36; 'charset:us-ascii': 0.36; '(in': 0.37; 'data': 0.38; 'supports': 0.38; 'values': 0.38; 'client': 0.38; 'received:org': 0.38; 'to:addr:python-list': 0.39; 'to:addr:python.org': 0.40; 'entire': 0.60; 'mar': 0.61; 'name': 0.61; 'results': 0.65; 'accessing': 0.66; 'regularly': 0.66; 'sounds': 0.66; 'built-in': 0.67; 'thomas': 0.67; '2012': 0.69; 'dennis': 0.84; 'iterable': 0.84; 'iteration': 0.84; 'with,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Documentation, assignment in expression. Date: Mon, 26 Mar 2012 12:16:57 -0400 Organization: > Bestiaria Support Staff < References: <4f6d0060$0$6634$9b4e6d93@newsspool2.arcor-online.net> <4f6f0d24$0$6561$9b4e6d93@newsspool4.arcor-online.net> <4F6F1792.1060709@tim.thechases.com> <4F6F222F.7050406@tim.thechases.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-253-99-231.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332778626 news.xs4all.nl 6981 [2001:888:2000:d::a6]:55918 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22201 On Mon, 26 Mar 2012 15:54:52 +0200, Thomas Rachel declaimed the following in gmane.comp.python.general: > Am 26.03.2012 00:59 schrieb Dennis Lee Bieber: > > > If you use the longer form > > > > con = db.connect() > > cur = con.cursor() > > > > the cursor object, in all that I've worked with, does function for > > iteration > > I use this form regularly with MySQLdb and am now surprised to see that > this is optional according to http://www.python.org/dev/peps/pep-0249/. > > So a database cursor is not required to be iterable, alas. > Sounds like it may be time to do a survey... MySQLdb iterable cursor Cursor, DictCursor, SSCursor, SSDictCursor (the first two suck the entire result set to the client and then feed it to the application, the latter two keep the results on the server and fetch them as needed; the Dict versions obviously return dictionaries, the others return tuples) SQLite3 iterable cursor Dictionary-like cursor using a row-factory (in Python 2.5 documentation: 13.13.6.2 Accessing columns by name instead of by index ) Psycopg iterable cursor dictionary-like cursor http://initd.org/psycopg/docs/extras.html#connection-and-cursor-subclasses Pygresql iterable cursor dictresult() ? py-postgresql unknown -- the only documentation I found appears to be for the NON-DB-API interface Row object supports index or key access pypgsql NOT iterable (based on readme and source) Result object supports index or key access Can anyone add to this? mxODBC, pyodbc, M$ SQL server? One thing I note in the above is that ALL of those adapters have built-in means of accessing return data as a dictionary, so the OP's generator function to create dictionary values is likely superfluous, and may even be a bottleneck in processing. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/