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 1mbsBm-00007W-FI for psycopg@arkaria.postgresql.org; Sat, 16 Oct 2021 22:30:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mbsBj-0000zF-LS for psycopg@arkaria.postgresql.org; Sat, 16 Oct 2021 22:29:59 +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 1mbsBj-0000z6-EE for psycopg@lists.postgresql.org; Sat, 16 Oct 2021 22:29:59 +0000 Received: from mout.gmx.net ([212.227.17.21]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mbsBg-0004Ls-Tj for psycopg@postgresql.org; Sat, 16 Oct 2021 22:29:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634423387; bh=Mzbcrfq6sr9RHkS7hlvZg9w7rXlwBX1ShiLUThXSk+E=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=avhOJPGps0L5DjsZAPvMkWFmrjlWMayazR9x6SMXCMySX6MXikSxlQly1v5QfL3KO Atci7j6zyc+D6tadMpcYBzgZ3RRGFnP602Q5zOwz+Aj7t5iV4byxRWLJgoIFyiYdvN UW7b+KrDIccYhTNlM7OIwA4ZSywTMXdHk4pH6K1k= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from hermes ([77.11.30.125]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MrQEx-1n76XU07RH-00oWY0; Sun, 17 Oct 2021 00:29:47 +0200 Received: from ncq by hermes with local (Exim 4.94.2) (envelope-from ) id 1mbsBV-0001Id-5Q; Sun, 17 Oct 2021 00:29:45 +0200 Date: Sun, 17 Oct 2021 00:29:45 +0200 From: Karsten Hilbert To: Adrian Klaver Cc: Daniel Fortunov , Daniele Varrazzo , Paolo De Stefani , Psycopg Subject: Re: psycopg3 transactions Message-ID: Mail-Followup-To: Adrian Klaver , Daniel Fortunov , Daniele Varrazzo , Paolo De Stefani , Psycopg References: <9a99d2d110b121542d1ea0a05066858b@paolodestefani.it> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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:GqtnK+e0YT/z7kn06GS4eO3I3Cun6xZyRlUlB7CxZ+ym6KwkqVx HFb2RuoNc3r110O6Ze67RZen/uqYzYCpHEuRDtCyObtE7nBNu7V1pEQAsHxm9t9FZJ0sHSZ 56Hvx0KVsmNX9/1ydzXssfBCXCNpR+GDbBu+ZkFqAtV+0nYSmV7pq4t0Vz44hRBIcXlHlMe jcw2BsOSdoeurFmyS+bLg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:FnZxWBWAaSM=:/mRx6UgZi9EOf0Mm23OY6V ri8rxGtdRygZ/tGL5pjzNKT9Ywz6yMU2UcW+yW1jpV8m25tcZlW2hykPJedqzcXjAIiGRZzv2 jpu6frFHKcX16+vaJrJs2Yl8PBbPykCoCqM26PZmWsOhh6i+iMMgY4Q8d9HUECMHZuVHrsZY1 nVrdJ2uT2dRm511wMrDQNI+iKJWWpLaMn3hySnoTTxwmQSAcJwfDXyGoH12kLjWHfeOJDZG8h v9VxxhbRodElhJ72yCJU/aMyxV6a31ASJKiNbMKaiQY4+1VNX5Van4HRadYPKz3XvoVat4UWb qTXt9lR35fUKUu1MmEGjSFT27eRYmWw0WI0qNxFFKJUdPbcjZXdz+rP/BTZYgjKvxmsIwpjs7 FUR7Kbk0E52eweVDPDWRB/VbpK+mtny+2qEefXiLk0hCyFkrGFwTwINjcNvC/ymY3NUK6CbJv o3bCazG19zsW6ibc6JVG5SJtt42NLCu8oI/I7bSALyAivboZMh+sAtkutF9ShC6RcGTu1BxVX 5DbqZML2ffrfIF9vjqNbomh+3sadc5cmVXljVJultH+ivGyIANmM2FndOzbETR3o0JfbSIsY0 GDJDzUuFShhWtT1cWeaZ6pOr6kMy3Yx4CeLjLrKrOLJUrxlvD67Ly8ykcU2cHgxDn7ZiTLfTQ /LwRTEmXQZGbzLv4wsCA2DUcmd9oTFHnT8T0+cgh7AJuSbw9wKolSJGENP1pa4QzWZXQpBegd HYG32JGaB3VISeYP74wEe10vDd5OZKQInpUpPJpew2xSszuNu6VA9/2Hp+eOXQ31aJkPoPRLF vmqa6DICq674ZHCD4ecxKY+5/VEqJ4hmM57Gx3oU7//9333T3AvBYoHXQHNMa49PNGpZNTNfg bHqs1WG2dR7123sHLW1XdQKTk4GISydlUrg8YlSwVq5RVDCvYvn2GK1ZJuOt1sMDF33TZOYLc zZRN7soCoy5ZO444okmosD+6fUb+6dQgzTBTg0OuPsnbedoT0FPfdJbg2ZVIx4GmvE1UJskgi NvGBItX3QPal6GslzDxNky0Kkfj2dYNkSW7PgDUrhE7fw2xZHqUOy+bXk9zxEOmNLrcvHyJZX ztuc9bs2fBoZM4= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Am Thu, Oct 14, 2021 at 03:38:21PM -0700 schrieb Adrian Klaver: > >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. > > If I'm following that option exists: > > https://www.psycopg.org/psycopg3/docs/api/connections.html#psycopg.Conne= ction.transaction > > force_rollback (bool) =E2=80=93 Roll back the transaction at the end of = the block even if there > were no error (e.g. to try a no-op process). Yes, but I would argue that force_rollback=3DTrue should be the default. Best, Karsten =2D- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B