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 1mdVuH-0003o6-LK for psycopg@arkaria.postgresql.org; Thu, 21 Oct 2021 11:06:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mdVuF-0005pr-UM for psycopg@arkaria.postgresql.org; Thu, 21 Oct 2021 11:06:43 +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 1mdVuF-0005on-N7 for psycopg@lists.postgresql.org; Thu, 21 Oct 2021 11:06:43 +0000 Received: from mout.gmx.net ([212.227.17.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdVuA-0003Na-Qw for psycopg@postgresql.org; Thu, 21 Oct 2021 11:06:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634814395; bh=/ZFQEEsCeOv7INz3UTDUyGdlwSxY+6qguRLaVgxcLXI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Z8wUhHCws+qkdboRT/MzoDCKMXCxa2WsYUAgxdH/ydplpvn4YOEmpvsy5Xj74y6JR rW8ZVz3J9WYJiWPZMXEOw7sJqLtBanHGLJJeuUA2AbZJPJqSkG/+reiQcqWBA6E5L4 mWEw5WS3lE9LS2yGcy3L1AycASRTR8DmgzmpBEkg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [217.91.207.107] ([217.91.207.107]) by web-mail.gmx.net (3c-app-gmx-bap69.server.lan [172.19.172.69]) (via HTTP); Thu, 21 Oct 2021 13:06:34 +0200 MIME-Version: 1.0 Message-ID: From: Karsten Hilbert To: Daniele Varrazzo Cc: Paolo De Stefani , Psycopg Subject: Aw: Re: psycopg3 transactions Content-Type: text/plain; charset=UTF-8 Date: Thu, 21 Oct 2021 13:06:34 +0200 Importance: normal Sensitivity: Normal In-Reply-To: References: <9a99d2d110b121542d1ea0a05066858b@paolodestefani.it> <6683df3e65fe961aa478e61db7ad687d@paolodestefani.it> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:+OP3EwMYdX2bqHQSn4bb3T/16SkgWjUxdaixt8vQAU6qSWgtgMAUCxZ4vRB3Yva31kjmG p9Y71QIGBynR5NZr4Cta4QdHTDDhUapeeVVJrhU93IFX4k4/prV93wKIU0RhRAuFZJXmes6cdZsO pFr6tbkspmmUlPc8fxKQT7qUWzeUVVR/zsbtg3GgZ9EYE5oxzOIMJrx/Ajx6YXBbcs+79bQ5wpm+ rL3E2djzTF+N+oaOrqDvryWpt1F98LmZ3qj8To/lgbId4xhGQ6BozyJMMrDuLCvE04OTT3GXhGDB ec= X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:hH0tbbzh9+U=:R517Z6mU/nI8ioCDFa/QzV 1mw83/l7aNdTp58Rr+R1fmBbxZZGSG7oGFVlzySjKD5UnV1LtUsTttZwl32B9tnarYFP6UeJK 1090Uir9B50N/uzV0TLopUKXOs45yFmODgNxF1ZoEchEdEMhTEQ/dEwgpAwHUWQKIaaP49Rw9 lbLqmDN+OdKKJ+CkuWIM0ii97THRaFOI0aAMPfkN3Me4cRvXLcULXShQss759woc0JoZTHBsd Eem0DWDjOKMP6Z2zj4J5By4ZMSJGNuR6BbprgD2/YTOE1j9SF37Nz4jxU7Jjs54YBlKDrAv14 ekdBIxoWGkXTloeLDIkt3JJFTo9o18kp9VFPUxfz19JxsY4ClhJarWXVOcBRVXXZrT0liLj1g 9sQaVSemqFS1e9mwBMybN0RWhHiV2QAuiCxIYFshFhbvzOjFTeLfCNzRLFyI0rsCRPiSaW62j bD/AW53JvDZmG5/A23sDS3iCAUIt1NdiHGqFiGaX9Vtfl3OF4OF7l/yXm7hu50BW48JBz4NHQ F1nyOMmZtf/fc4IfICB7BF5d8yakQZfhGsEMOIJMW7AzLaEL3KB5GfbhZfYO/fBqgBo/Ex/g2 f411a812NiaHGD/p6ZB3eQ/0YtDsDgz4q5Qp163YKo9eDLiUtbm1QvUaC8Wqw4vMJlZasY2NB gsG85o2bUHyqm97JsFEp8x9Efxn7f7MYon6PLha2+Yqr7d37Kxn+LpkpRFRj6IF+0j6XPDT1W jN7oP65iw3sePGbwsywG7Vnm4erRQ56DhrylSeYR18lI01948q7tTLjYICnbRfHhJssg9W7HN 0fnFwhx List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > The behaviour of a dbapi connection, without context block, is to just close the communication. The fact that this results in a rollback > stems only from the behaviour of the server But that's the whole point? A driver should _not_ (by default) alter the default behaviour of the other end, IMO, without extremely good reason. There _is_ good reason for the transaction context manager, but not for the connection context manager or plain use. > I think that using 'execute("INSERT....")' is already quite a conscious decision of operating on the database. I agree. But the decision is not "this IS to be in the database" (or else no need for transactions) but rather "this is to be in the database IF other, perhaps not even database related, things suceed". > asking that the program to 'conn.commit()' explicitly seems an unrequested, kinda ritual, final blessing. Exactly. > Sending an explicit ROLLBACK is an occurrence much more rare, Exactly, and thusly easily forgotten, with possibly dire consequences (in the case of default-commit, as opposed to default-rollback). Karsten