Re:Thinking Psycopg3
by quietbritishjim on Thursday March 12, 2020 @06:37AM
(#22555401)
> one has to create the cursor before ever executing any queries
You are right, that is a bit weird, although only a very slight annoyance IMO. As I said in reply to the sibling comment, I had forgotten this as I mostly use SQLite from Python and it doesn't actually require this: you can call .execute() on the connection object and it returns the cursor, which does seem a lot cleaner.
It would be much clearer to me that the cursor is an iterator if it was actually returned as the result of executing a query.
[1] https://www.psycopg.org/docs/usage.html