"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/delete, but not with select.

For a pure iterator-based solution, I would do something like this (admitly
a bit cryptic, but iterator-based solutions often are :-) :

async def get_uniqu(ait):
    async for row in ait:
        break
    else:
        raise NotEnoughtRows()
    async for _ in ait:
        raise TooManyRows()
    return row


Also nice - thanks. I now have a few to choose from without needing an 'anext()'.

Frank


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to