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 1l7yXm-0006f8-E6 for psycopg@arkaria.postgresql.org; Fri, 05 Feb 2021 10:40:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l7yXk-0004Ur-1k for psycopg@arkaria.postgresql.org; Fri, 05 Feb 2021 10:40:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7yXj-0004RY-QB for psycopg@lists.postgresql.org; Fri, 05 Feb 2021 10:40:51 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l7yXd-0005nL-H3 for psycopg@postgresql.org; Fri, 05 Feb 2021 10:40:50 +0000 Received: by mail-lf1-x12d.google.com with SMTP id d3so9151647lfg.10 for ; Fri, 05 Feb 2021 02:40:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=b9GqFfV6f1+Vtr+c/uX/zQdfU+Vf0DyBcFBGRYm+cCw=; b=T+ZasIpK1ZvzsHuY8Y9e/KGUDx7AwJusrfkbZQ+BQLzs49eVERSe8c+MyqGdgffSZE cGV8JtEuAsczC3jl5jcdAZsrqEkoEhcXSjms/PMwv4whLrVZZvUiJoXYIPvod0HtET0h 4o3ytkroMrzdG0bQkRRKSUqfcQajfp6j067B1hnMgl1qnMbuKhLKXsYN9BvxhDwy5uuP dQDIs0ByCEdzJ4f52sZVlikgpgdgHCtSp4S8DBsW4cKM8Q4/ZJH45wnVhweGUGBXZnwX W3hEFrPXtQgPnfZbBJvcfUd9fVsQqhSpMn7VGXcC7oSYjPkK1fJKXETydJa1T6RBQ9eh 7ulg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=b9GqFfV6f1+Vtr+c/uX/zQdfU+Vf0DyBcFBGRYm+cCw=; b=DJuBSpl4utOmmkegBnaiVc2RCvhIL5MtqQ8Ita5Y+1CjhrRW+VNO4XGdnIQ/9pliOd MPNi+zCDf070KTg9075EJTDzGpZvGacPXRMGjiANYfpXtE6aiHYbdiFKXmWJKA011wRX A1ylvd2Mug6A1IzKTew/RvoqZ7YJDd5BkAE/Gc9EFdLe2m7702KzQEexxzeekAF+4KGm ruclSxIuPxeZ8PuNyyD17tyZzyS2twGCJRuV2JrFQhWPYdBnIB4aNOQiPJFC9+Acu9S5 fzoDlCtrJCLKIZ82isUzaj/CEGF+FTpZS1eWm/o8SpLi9uTABrPRkI6fgVKLYB0lmID2 5Mpg== X-Gm-Message-State: AOAM532hfqbuCOKYhNTblpI8+nqQvvgdvVdGUgwx8MMWMrfpgneN8Au+ IcYL6WfILH9eU9lzPwvv2x64l1KFBiwr98wkCEc= X-Google-Smtp-Source: ABdhPJwsIBcQN7LWvQRmHTqjWF3PHNjZ+WdGuLgbZsvRG9h/Eb3qebmwOZ9QogrNmIVclZFTdqIMFvM1xLzdXwa0uhQ= X-Received: by 2002:a19:8603:: with SMTP id i3mr2157648lfd.404.1612521643526; Fri, 05 Feb 2021 02:40:43 -0800 (PST) MIME-Version: 1.0 References: <20210203161548.vkhu3qkpvmgvyhik@dalibo.com> In-Reply-To: From: Daniele Varrazzo Date: Fri, 5 Feb 2021 11:40:31 +0100 Message-ID: Subject: Re: about client-side cursors To: psycopg@lists.postgresql.org, psycopg@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, 5 Feb 2021 at 10:41, Karsten Hilbert wrote: > Given that people interested in using conn.execute() don't > seem to want to concern themselves with cursors at all (until > there's an explicit need, at which point they would seem to > want a server-side cursor, and use conn.cursor()), and the > fact that conn.execute() is outside the DB-API anyway, I > wonder whether this > > class connection: > def execute(self, query, vars) > cur = self.cursor() > cur.execute(query, vars) > return cur.fetchall() > > makes even more sense ? > > Perhaps even reconsider naming it "execute". If it didn't return a cursor, it would make sense to reconsider calling it execute(). As it is now it returns the same that cursor returns, it's pretty much just a contraption of a chain of methods, hence the same name. If you return just the fetchall list you lose access to results metadata (description), nextset, and someone will come asking "can I have executefetchone() please" the next minute :) I'll play a bit more with it in the test suite (which is currently the main body of code using psycopg3) and think about it. -- Daniele