"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)) # pull at most 2 rows
if not rows:
# no rows
elif len(rows) > 1:
# too many rows
row = rows[0]
I like the idea, but I don't think it would work with an asychronous
iterable. OTOH it should not be difficult to roll your own using the example
in the itertools docs as a base. Except that the example uses next(it)
internally, and this thread started with the fact that there is no
asychronous equivalent, so I might be back to square one.
But these are all variations on a similar theme, so I don't think it matters
which one I choose. I will go through them at my leisure and pick the most
readable one.
Thanks
Frank
--
https://mail.python.org/mailman/listinfo/python-list