Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Michael Torrie Newsgroups: comp.lang.python Subject: Re: Cannot step through asynchronous iterator manually Date: Sat, 30 Jan 2016 15:05:09 -0700 Lines: 25 Message-ID: References: <56AD122F.2030904@gmail.com> <56AD31E7.50407@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 6VSWPkuue2JjLqvwHf52Jwy+rx+HPhMClpYPLS8uy4mg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'alias': 0.07; 'column': 0.07; 'exception.': 0.07; 'matches': 0.07; 'part,': 0.09; 'spec': 0.09; 'sqlite': 0.09; 'throw': 0.09; 'exception': 0.13; 'count,': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'query,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'wrote:': 0.16; 'handles': 0.20; 'not,': 0.22; 'decide': 0.23; 'select': 0.23; '(or': 0.23; 'this:': 0.23; 'words': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'rest': 0.26; 'found.': 0.27; 'have,': 0.27; 'there.': 0.30; "i'm": 0.30; 'query': 0.30; 'michael': 0.33; 'him.': 0.33; 'null': 0.33; 'message-id:@gmail.com': 0.34; 'could': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; "won't": 0.38; 'data': 0.39; 'sure': 0.39; 'whatever': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'still': 0.40; 'your': 0.60; 'charset:windows-1252': 0.62; 'course': 0.62; 'more': 0.63; 'information': 0.63; 'wish': 0.71; 'frank': 0.72; 'hoping': 0.77 X-Virus-Scanned: amavisd-new at torriefamily.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: <56AD31E7.50407@gmail.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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:102316 On 01/30/2016 02:57 PM, Michael Torrie wrote: > SELECT count(some_id_field),field1,field2,field3 FROM wherever WHERE > conditions > > If the first column (or whatever you decide to alias it as) contains a > count, and the rest of the information is still there. If count is 1, > then the row is what you want and you can do whatever you wish with it. > If not, throw your exception. I'm not sure how SQLite handles it, or even what the SQL spec says, but I know in MySQL you could do something like this: SELECT count(id) as row_count,`tablename`.* FROM `tablename` WHERE condition and get the same thing as SELECT * would have, with the addition of a "row_count" field. Note that because of the count() part, the query will always only return 1 row. The fields will be NULL if the count was zero or they will contain the fields from the last row the query found. In other words if there is more than one row that matches the query, it will only give you data from the last match. Now if Frank is hoping to do work on the first row and then throw an exception if there's an additional row, then this of course won't work for him.