On Sun, Jan 31, 2016 at 9:05 AM, Michael Torrie wrote:
> 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 in
On 01/30/2016 02:19 PM, Chris Angelico wrote:
> where the ... is the full original query. In other words, the whole
> query has to be run twice - once to assert that there's exactly one
> result, and then a second time to get that result. The existing
> algorithm ("try to fetch a row - if it fails
Michael Torrie wrote:
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
I don't think that's strictly valid SQL. I know of at least
one SQL imple
On Sun, Jan 31, 2016 at 9:19 AM, Michael Torrie wrote:
> On 01/30/2016 03:06 PM, Chris Angelico wrote:
>> That actually violates the SQL spec. Some servers will accept it,
>> others won't. (You're not supposed to mix column functions and
>> non-column functions.)
>
> Are you sure? Wikipedia is no
On 01/30/2016 03:06 PM, Chris Angelico wrote:
> That actually violates the SQL spec. Some servers will accept it,
> others won't. (You're not supposed to mix column functions and
> non-column functions.)
Are you sure? Wikipedia is not always the most accurate place, but they
have several clear e
On Sun, Jan 31, 2016 at 8:57 AM, Michael Torrie wrote:
> On 01/30/2016 02:19 PM, Chris Angelico wrote:
>> where the ... is the full original query. In other words, the whole
>> query has to be run twice - once to assert that there's exactly one
>> result, and then a second time to get that result.
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 wh
On Sun, Jan 31, 2016 at 8:52 AM, Michael Torrie wrote:
> On 01/30/2016 02:19 PM, Chris Angelico wrote:
>> Efficiency. That's a fine way of counting actual rows in an actual
>> table. However, it's massive overkill to perform an additional
>> pre-query for something that's fundamentally an assertio
On 01/30/2016 02:19 PM, Chris Angelico wrote:
> Efficiency. That's a fine way of counting actual rows in an actual
> table. However, it's massive overkill to perform an additional
> pre-query for something that's fundamentally an assertion (this is a
> single-row-fetch API like "select into", and i
On Sun, Jan 31, 2016 at 6:42 AM, Michael Torrie wrote:
> On 01/30/2016 01:22 AM, Frank Millman wrote:
>> There are times when I want to execute a SELECT statement, and test for
>> three possibilities -
>> - if no rows are returned, the object does not exist
>> - if one row is returned, the
On 01/30/2016 01:22 AM, Frank Millman wrote:
> There are times when I want to execute a SELECT statement, and test for
> three possibilities -
> - if no rows are returned, the object does not exist
> - if one row is returned, the object does exist
> - if more that one row is returned,
On Jan 30, 2016 7:13 AM, "Oscar Benjamin"
wrote:
>
> I haven't used PEP 492 yet but what about:
>
> async def aslice(asynciterator, end):
> if end == 0:
> return []
>items = []
>async for item in asynciterator:
>items.append(item)
>if len(items) == end:
>
On 30 January 2016 at 16:42, Ian Kelly wrote:
>> AFAICT there's no generator-function-style syntax for writing an async
>> iterator so you'd have to make a class with the appropriate methods if
>> you wanted to be able to loop over aslice with async for.
>
> Before you go any further with this, be
On 30 January 2016 at 13:45, Frank Millman wrote:
> "Oscar Benjamin" wrote in message
> news:cahvvxxsa0yq4voyy6qycgxxvpl5zzgm8muui+1vmezd8crg...@mail.gmail.com...
>>
>>
>> The simplest thing would just be to call list(cur) but I realise that
>
> you don't want to consume more than 2 rows from the
"Oscar Benjamin" wrote in message
news:cahvvxxsa0yq4voyy6qycgxxvpl5zzgm8muui+1vmezd8crg...@mail.gmail.com...
The simplest thing would just be to call list(cur) but I realise that
you don't want to consume more than 2 rows from the database so just
use islice:
rows = list(islice(cur, 2)) # p
On 30 January 2016 at 08:22, Frank Millman wrote:
> There are times when I want to execute a SELECT statement, and test for
> three possibilities -
>- if no rows are returned, the object does not exist
>- if one row is returned, the object does exist
>- if more that one row is returned
On Sat, Jan 30, 2016 at 11:35 PM, Kevin Conway
wrote:
> To address the original question, I don't believe a next() equivalent for
> async iterables has been added to the standard library yet. Here's an
> implementation from one of my projects that I use to manually get the next
> value: https://bp
> Any particular reason not to use the classic sentinel object model?
None that I can remember. I would use the sentinel pattern if I were
writing it again today.
> Also curious is that you raise a new StopAsyncIteration from the original
one, rather than just reraising the original. I assume the
"Chris Angelico" wrote in message
news:CAPTjJmoAmVNTCKq7QYaDRNQ67Gcg9TxSXYXCrY==s9djjna...@mail.gmail.com...
On Sat, Jan 30, 2016 at 7:22 PM, Frank Millman wrote:
> We had a recent discussion about the best way to do this, and ChrisA
> suggested the following, which I liked -
>
>cur.execut
"Maxime S" wrote in message
news:CAGqiJR8yUdd1u7j0YHS-He_v4uUT-ui=PpiX=n_G=ntt8zn...@mail.gmail.com...
I might be a bit off-topic, but why don't you simply use cursor.rowcount?
I just tried that on sqlite3 and pyodbc, and they both return -1.
I think that it only works with insert/update/
To address the original question, I don't believe a next() equivalent for
async iterables has been added to the standard library yet. Here's an
implementation from one of my projects that I use to manually get the next
value: https://bpaste.net/show/e4bd209fc067. It exposes the same interface
as th
2016-01-30 11:51 GMT+01:00 Frank Millman :
> "Chris Angelico" wrote in message
> news:CAPTjJmoAmVNTCKq7QYaDRNQ67Gcg9TxSXYXCrY==s9djjna...@mail.gmail.com...
>
>
>> On Sat, Jan 30, 2016 at 7:22 PM, Frank Millman
>> wrote:
>> > We had a recent discussion about the best way to do this, and ChrisA
>>
"Ian Kelly" wrote in message
news:CALwzid=ssdsm8hdan+orj54a_jeu9wc8103iqgkaah8mrj-...@mail.gmail.com...
On Jan 29, 2016 11:04 PM, "Frank Millman" wrote:
>
> Hi all
>
> To loop though an iterator one usually uses a higher-level construct
> such
as a 'for' loop. However, if you want to step t
On Sat, Jan 30, 2016 at 7:02 PM, Ian Kelly wrote:
> On Jan 29, 2016 11:04 PM, "Frank Millman" wrote:
>>
>> Hi all
>>
>> To loop though an iterator one usually uses a higher-level construct such
> as a 'for' loop. However, if you want to step through it manually you can
> do so with next(iter).
>>
On Jan 29, 2016 11:04 PM, "Frank Millman" wrote:
>
> Hi all
>
> To loop though an iterator one usually uses a higher-level construct such
as a 'for' loop. However, if you want to step through it manually you can
do so with next(iter).
>
> I expected the same functionality with the new 'asynchronou
On Sat, Jan 30, 2016 at 7:22 PM, Frank Millman wrote:
> We had a recent discussion about the best way to do this, and ChrisA
> suggested the following, which I liked -
>
>cur.execute('SELECT ...)
>try:
>row = next(cur)
>except StopIteration:
># row does not exist
>e
Hi all
To loop though an iterator one usually uses a higher-level construct such as
a 'for' loop. However, if you want to step through it manually you can do so
with next(iter).
I expected the same functionality with the new 'asynchronous iterator' in
Python 3.5, but I cannot find it.
I ca
27 matches
Mail list logo