Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kmdOd-0007ck-Kr for psycopg@arkaria.postgresql.org; Tue, 08 Dec 2020 13:51:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kmdOc-00025z-Jf for psycopg@arkaria.postgresql.org; Tue, 08 Dec 2020 13:51:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kmdOc-00025s-3K for psycopg@lists.postgresql.org; Tue, 08 Dec 2020 13:51:14 +0000 Received: from mail1.dalibo.net ([212.83.143.11] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kmdOX-0001Oc-QT for psycopg@lists.postgresql.org; Tue, 08 Dec 2020 13:51:13 +0000 Received: from [192.168.0.29] (lan31-5-82-234-69-236.fbx.proxad.net [82.234.69.236]) by mail.dalibo.com (Postfix) with ESMTPSA id 3E51420489 for ; Tue, 8 Dec 2020 14:51:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1607435467; bh=dHqgL9C2xgtUlWmlcq1wsEBfDA7ld3rAnZzCYhLWsGk=; h=Subject:To:References:From:Date:In-Reply-To:From; b=p50D+m7harlSTyStVi0c7HPr4/J1Emw1nTmgz+7xJyNxcQq6hK2yoIyE9Z8pjVKEe S4Ls7T+zPSvv3ROSHEYSXHnN5QJu1Oon9o1naiLoLfG7fpK8qITXbnqHKWYrq1KnMb Eph53epIwbjVFPqD5nH1gb+HgHw9Q/1rZ+6QS7Lc= Subject: Re: Executing on the connection? To: psycopg@lists.postgresql.org References: From: Denis Laxalde Message-ID: <7171e07d-bb96-dfc6-47e9-351d85f4a973@dalibo.com> Date: Tue, 8 Dec 2020 14:51:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Daniele Varrazzo a écrit : > On Wed, 2 Dec 2020 at 11:20, Daniele Varrazzo > wrote: > >> I'm toying with the idea of adding a 'connection.execute(query, >> [params])' methd, which would basically just create a cursor >> internally, query on it, and return it. No parameter could be passed >> to the cursor() call, so it could only create the most standard, >> client-side cursor (or whatever the default for the connection is, if >> there is some form of cursor_factory, which hasn't been implemented in >> psycopg3 yet). For anything more fancy, cursor() should be called >> explicitly. > > This is what I've pushed earlier: > > https://www.psycopg.org/psycopg3/docs/connection.html#psycopg3.Connection.execute > 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? Otherwise, that's a very nice addition, thanks!