Re: Executing on the connection?

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Denis Laxalde <denis(dot)laxalde(at)dalibo(dot)com>
Cc: psycopg(at)lists(dot)postgresql(dot)org
Subject: Re: Executing on the connection?
Date: 2020-12-08 14:56:14
Message-ID: CA+mi_8YgOjGA3P9sBY4nVsE=_f6BbCi3OE-ZPz=LZoP5yEtedA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Tue, 8 Dec 2020 at 13:51, Denis Laxalde <denis(dot)laxalde(at)dalibo(dot)com> wrote:

> It did not strike me earlier, but it looks a bit weird to have
> connection.execute() return a "cursor" to read results while this
> "cursor" can also be used to execute commands. So, perhaps, another
> object, with only the interface for result retrieval would be more
> appropriate?

It thought about that, and it would be weird if people used a cursor
for further queries after consuming it, yes. But hey, who are we to
deny them to do that? :D I wouldn't go about creating and maintaining
new objects and interfaces only to limit the possibility.

My idea is that those who are interested in using `conn.execute()` are
exactly the people who don't care about having execute() on a cursor.
I think there's no harm in leaving it there :)

-- Daniele

In response to

Browse psycopg by date

  From Date Subject
Next Message Hagen Finley 2020-12-20 23:13:33 BACK: Inserting a variable into cur.execute statement
Previous Message Adrian Klaver 2020-12-08 14:44:56 Re: Executing on the connection?