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 1l7xcL-0004QJ-21 for psycopg@arkaria.postgresql.org; Fri, 05 Feb 2021 09:41:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l7xcJ-0001gZ-Oz for psycopg@arkaria.postgresql.org; Fri, 05 Feb 2021 09:41:31 +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 1l7xcJ-0001gR-IY; Fri, 05 Feb 2021 09:41:31 +0000 Received: from mout.gmx.net ([212.227.17.22]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7xcE-0005MX-P2; Fri, 05 Feb 2021 09:41:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1612518083; bh=knGMs2ckjpglxUDVCGcuSgZ6zjbn4Ji5ig/NogUJZHk=; h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To; b=aaQ7dATgbOZBHuReNkzkl56njiXmg0L9qcjv8GkG5XZ1QaWc7bPU6Y4iiuMfwfBMR izNDliZQ5MoAhaUxFgCHuZ3KsDZdIY5hl2/u27//t4MS8r92v8wW73FYn25o5yYThF ZBtBss441eBwp9hJzHWMRThpw6L3t5e+2k1ZC0SY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from hermes ([89.14.26.2]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M72oB-1l0Wy53DX5-008ZuU; Fri, 05 Feb 2021 10:41:23 +0100 Received: from ncq by hermes with local (Exim 4.94) (envelope-from ) id 1l7xc9-0004Ry-3Y; Fri, 05 Feb 2021 10:41:21 +0100 Date: Fri, 5 Feb 2021 10:41:21 +0100 From: Karsten Hilbert To: psycopg@lists.postgresql.org, psycopg@postgresql.org Subject: Re: about client-side cursors Message-ID: Mail-Followup-To: psycopg@lists.postgresql.org, psycopg@postgresql.org References: <20210203161548.vkhu3qkpvmgvyhik@dalibo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Ma_X_il-Followup-to: d Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net X-Pri_X_ority: 2 (High) Sender: X-Provags-ID: V03:K1:fKY44silTXv7b3twvFuaA/nB0tKyowZxX0+AOh5Q6+SnpQh2Ud+ 4mCfbXC5n//6lhDEAUBaRm8wyHKo50Q1fpbSvE35BJPL+VVbWq97WFtiX5lzgb8flCQt9Ip 88LlDq2/VMJnYzvRxeGQOTJg4SjDaBKTdjZIVOQ2U+PAK8URKufLRCQ83mZQfOy4CtcLIw+ ziaZMP+n6FOaQai4NaTpA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:6JcMehK6FRM=:HJZ+xf7vRIRDQs4JZ4/SFt PALTtyf7WVdBiNRVmK4t3bm3iaszE2s5c7A/2iaWtLiY21ZaHFv/kd59Ux16tD52M24giSNYe 1lfMzCtyjmPMcxhf+/O4jQwDuC7rNQCo0Gu7EPYrU3aKdlE5N/GmvEI8UzO56AdX1DBMG7cbN q8ru6Zvfg/GN5yL9rEn2N/n7Fwel+ieqNPb8K/pQz4jpITZ6c8sgdHiwB5PcWmlChHN8uWDbr wlVbRixXP6HtjQF3tmIk/RXj1fuwweY0TIlU1ErQ7bg3VEG5clXg2DJZFk7rUBPWdkDYubCKE pob5DYA7OWzK1iv7EnDaooJsYxinUdCXTHQ4liBvOylKHnyIf6qPB0fg/Y0/SUWx31qSlLhsz Lz/uq66JUokp/P5t4xdtzplR1Y5IIwRXHgfeuXVarWiGypZHMr0hBSXNPmdBze3o5fxGFb1cs dJy0dzOsK4sjXA8fQ7t+SCMJgYxGo8PjlzYPD+qgLrsBXM8e148a9WOrF3uAV6jzTVZPRo/4B vsotveo0/Y2kLyNohG0SMl2l05voNMhcXXWwZe2tJ+a+wCve4ID8J92c4TUg7KEBvBN/Aj98m 9O8P2ii/pILF8sFGJgcPyRbzq1prs0X5w5MmfKcMy1oeNjmLJs3GSl+ad575DQZx1+7W9fmeG AuRx9NXCFiuGH3dfex/P/U8fzJFb7c5dThSCq4QUCKMPRXo0C2877+4307OeDiEsvCXlHx65k xOrTjTLX5DWYDk1bzE2ISPydnkExHEjql+PtsC/advVOeFtRYUX60TEHePaXasi7EE0hH6daD uoFpnBp23e1q5YNJ0YUfvGjCTbGZvwpFpsrRd7D+WVnWzykrF3lnDkxcQp/euwrJbLWuujIYC 2XTqSShig3896cSc4dVQ== Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Am Wed, Feb 03, 2021 at 06:44:33PM +0100 schrieb Daniele Varrazzo: > Yes, that's correct: the name comes from the dbapi. The dbapi cursor > does two different things indeed: it runs queries and manages results. > I understand that the overlap is sort of weird and everyone who has > said "psycopg sucks: let me write my own driver" have used the mental > model - much more familiar - of "I ask a query to a connection which > gives me a result". So usually what is created is something which can > be used as: > > result =3D conn.execute(query, vars) > for record in result: > ... > > This is understandable, so much that in psycopg3 I've added > conn.execute, which is implemented as: > > def execute(self, query, vars) > cur =3D self.cursor() > cur.execute(query, vars) > return cur > > and allow you to use the cursor only to iterate on the data returned, > ignoring the execute*() methods. 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 =3D self.cursor() cur.execute(query, vars) return cur.fetchall() makes even more sense ? Perhaps even reconsider naming it "execute". > The Server versions have I/O done on fetch*() and on close(). So the > first three objects might have non-async fetch(). I was preferring to > give all them an uniform interface +1 Karsten =2D- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B