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 1mb91h-0000XP-O1 for psycopg@arkaria.postgresql.org; Thu, 14 Oct 2021 22:16:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mb91g-0002RN-I2 for psycopg@arkaria.postgresql.org; Thu, 14 Oct 2021 22:16:36 +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 1mb91g-0002RE-B8 for psycopg@lists.postgresql.org; Thu, 14 Oct 2021 22:16:36 +0000 Received: from mout.gmx.net ([212.227.15.19]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mb91e-0007ZY-7q for psycopg@postgresql.org; Thu, 14 Oct 2021 22:16:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634249788; bh=uT964uV+/msiTKIoerXVbpKI5u9biVUFX8OLaWMGKak=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=XIEOwoihJt1zFF3pntgi3kNMs6kgnnlxq04zDuOT3XHEsU6hjle50bi7XkcQzUNxw E6WTMeNF0hPORPCt+poV5Z9BjXHH4kyOTg9j5POdFMPooJEdkcZFLKfvRI8i05OrNd QjUoizA/+XJooDPWDtVVXZz+ToWmRFkQA7MnEhMc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from hermes ([77.11.240.209]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mlf0K-1n1vJp3BZK-00inc9; Fri, 15 Oct 2021 00:16:28 +0200 Received: from ncq by hermes with local (Exim 4.94.2) (envelope-from ) id 1mb91W-00057Q-0X; Fri, 15 Oct 2021 00:16:26 +0200 Date: Fri, 15 Oct 2021 00:16:25 +0200 From: Karsten Hilbert To: Daniel Fortunov Cc: Daniele Varrazzo , Paolo De Stefani , Psycopg Subject: Re: Re: psycopg3 transactions Message-ID: Mail-Followup-To: Daniel Fortunov , Daniele Varrazzo , Paolo De Stefani , Psycopg References: <9a99d2d110b121542d1ea0a05066858b@paolodestefani.it> 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:SoCFaUrrSmdjI6xgVtV1D16DQ9kLtCZPLtfphoMda2rSw1Q2ve6 bTaGsnHD5mRmoTNIs173jHqwfTIQfRGwxJoUQdUhRM4Q7L+eNTBoEAy2kPri7bYyYVcPJnN cwxJBHsxNgxMS9kTBdfxFI4Yc2xUew8JKPG3h+vNR2P14yCZpnNq/VxiCNR8J0aq0to1nJ2 mif1pe4rf29iQuu2uIQnQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:lNizhubFDh0=:koZOOzfyX0h3h9EVaGtEaU 2RX6Xr/nzv/2T+KP3xADKWqkAc7hspNlKFurQh+soh6R08BSt8HPK7FWKLowSCPY2msUmj4Mg CHNFMEq2Gn6qkxqSrAa8gfg3Vg5L9R2cVreqzA4kLjc2HDu4FPW7ZTgCABwc+EgZOwu8CdlFJ OvC35Vpjh+r1lGiG36dJ9vxwe0iUZlyTmvcRrsGIy6GVdr8e1G3eoor1DdvpZUvfjNDT8Q/M4 ri6RAp78FeprXdIoRRTDftU7skdDPi8aP4t8ol7R2oJVdjzeySvP4XC784r4RkZ4hax/tfDWg TYAn0bYnmIkb06z/WN/KIRdymOh3d9gCTVYY93oNZozlb0jI7fIoczedASxqbwGqQL38RqYBe Enlvyj/xQg4X3imBHDKiasK9hOOoy7HleU05aUxr/cQ2a6v/rvn2kMIswhVyDUny3wTJZ5WJm cUznOBn6vGHHyTSJeg1s6yCzAC5fUviUAC+0UnoC+Xl6Ox7PLIPanO7pLtL952ytINSg6CcCh hzlD3F/eTfEontSHBl+aFC3VY2ppU5FIedTjyXce3JJRfDN4xFOJsE8caHJySPYrdec0cgX7v thud5R4eOHuvSMoyYmZMB77hpoIyO8v284pVFVm5tGajs1cl98H5ongKs0OhS5OoFHw/Vz5he wIe4DmXdJyaR5tb/jZMy2QMCrnml/bOuzJkcEBMFwyy+OA0YrbchkymEzSCyJHpKo7xQ5I4Hn mD16ml6PORydaGSssDbAmtiBJXlQQXhJkOzjDdiEzNE/PQ1a/0N/Vkxcfj83u11/9M07MIl/z LB94OXO0hNAnefZFIj6Xv4kWULGPPzxGYwYvnOkODih0eHgAw2yLydtfMdv1CqFDOuPxlDUlM Lv4mTd0hEOxXncJhhQtpr55u9dQnQFhHy/ZTcO43HaPwdGdZSINDC2NzJcj+TF4VLMw0O6y4M nIYAzSZEA0yUbewoukw/5ObLHqwWmQj3Gn1Q5to5mgxkM13s6kLOzUW23SujZyq1F3lWI7vqp I+Ze37SlVjbyZF04AE2xpBWRZe6TaJ4b02Qnmimz+RGeAy61zuyEKE/1c7jbrKK183rXnKHve Y7Ps1cFRIwA++c= Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > We are still "using transactions", just with more precise, more explicit= *, > and more flexible* semantics, represented by a context manager. > > Rolling back a transaction is possible by raising a Rollback exception > within a block. > > I hope this answers your question but if not please describe the scenari= o > you are thinking about. Personally, I think the autocommit=3DFalse approach is somewhat safer (more conservative) for the data: One *always* is inside a transaction, and the default behaviour is to rollback. Nothing is by accident automatically committed -- which can happen with autocommit=3DTrue. I would certainly suggest that a context manager calls .rollback() during teardown rather than .commit() -- the context manager cannot know whether actions really are to be committed, even if technically possible. Karsten =2D- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B