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 1mbsdq-0001Sk-Qc for psycopg@arkaria.postgresql.org; Sat, 16 Oct 2021 22:59: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 1mbsdo-0003b7-W6 for psycopg@arkaria.postgresql.org; Sat, 16 Oct 2021 22:59:00 +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 1mbsdo-0003aw-Pz for psycopg@lists.postgresql.org; Sat, 16 Oct 2021 22:59:00 +0000 Received: from mout.gmx.net ([212.227.15.15]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mbsdl-0004Xk-MI for psycopg@postgresql.org; Sat, 16 Oct 2021 22:58:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634425129; bh=PWl8g5wFytoIR7oYwqejiwEefxzOl9C49JUrrCb5QsQ=; h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To; b=UPhVostvgGfric8PJAt5rzVkDQ2l5w4OSIa7HCPkITCGwMyHufOMVCk90xc4xMl0U 0FFEH5MgnF0hUxajqyvVueAc+9mK6U+QbqVFZ2lA7pbai9CeH5Fk5M8mnp13LczCSG 1xUnx5eMKXBHHGWPiEZh04H9oFLc1jTtcj7+S1yI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from hermes ([77.11.30.125]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N0oBr-1myl9I0gPV-00wiMF; Sun, 17 Oct 2021 00:58:49 +0200 Received: from ncq by hermes with local (Exim 4.94.2) (envelope-from ) id 1mbsdc-0001nB-4O; Sun, 17 Oct 2021 00:58:48 +0200 Date: Sun, 17 Oct 2021 00:58:48 +0200 From: Karsten Hilbert To: Daniele Varrazzo , Paolo De Stefani , Psycopg Subject: Re: psycopg3 transactions Message-ID: Mail-Followup-To: Daniele Varrazzo , Paolo De Stefani , Psycopg References: <9a99d2d110b121542d1ea0a05066858b@paolodestefani.it> <6683df3e65fe961aa478e61db7ad687d@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:6aBRqbAhKwEUBdYh2HwXj3icyVXi9yHPUYkECcQK18jmBIPxKFu AZef7lU441bHEfi0N4dXIOt5Pcd7/TujwRl6BijL5zVgVXSD2MSiKWq/pJcpJcSiG6tev4d yspftcPQthkVEFEdRKjZbyt2uRIW+CVfL0Aj3HvAe0BaZAj+GUVhKkWCzAcEKA6HL22BCu3 hY2mzUltg+r8WtVCp3ALA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:VzFNnjp5aJo=:BOASeS1AvvY8wkGCfejD96 WjxNyXTg7fNIueL9UIRwofKgpX7qn9nUayhIACQFlq2OZf22HpFzuzZ9G7uKOoxE+Qju+6TXy 8EbyWOu39mC9Xj/5hky0n8jsRThgBN4TqY6J64sfKm3k5YevrumD+R9NiTrh1vm9sMAjkqwaz UvRDtjK4scGPSOdqYfkgnTJQ53vbPIfd2NcxOqk6DP3HpuRyvLuTQH98UKgfZsXD11gpEWshW hyah9cE+7BDCfyjn0AsYW8pgfJv5VFFLgSE+Ob+ApfzkFzyiAF1LF0oOaZs4wyirwIT/eDYH8 d8OoqIiHjpr821RCmMn8RnUCMxus0TU3xOyyOo77Z8KkBl0ji41w/bbfGGUvXSTAP+JpRsk0i Uyrh4Dq2/SmxNbk9iouLcOiRl1afMpKXcXu19MiIybwq58XFYLL9I28dz0a0gkpKw7G/6o5yJ 1paFvWloKRl1kl1fmaCsDWdqtSy7kF0nd5Ikoh/2LKrIGfnFLqJMzHlRXYjywpqtNcZngcd/y UhgzCwjqIeCBdR7+LXYHXIrp+I/2uiQNEKMc32KDmmmMQoHSgUg8egB0YgQONVl+79Gdgw1Bm OL32ll5OmQfdBra0wk0nTeTGI46m101FIE4weXwiRsjCb+LhJ1iU92bShl6fsdgfxsBVex3Gh cV5bXtOs5YfaQeD5dD4TWUtucIE9QPTxEz2YSljLBxejp+SmrQpPwm+8MXs7zGF8Oc6qD40RX cVmYM3K8N988LjOfU7tT4HuF3WkhQ9gvoTyEXIaZVHlFk1dGN7vmblE5lZ3TeUqI+dEKbdI4C 8WruLHreKEYhfn84cGvLjUVDCdhdAAgeNTchGYGSvHlLCd1J7f2mfTVGQxxdaD8NbFAhcexOU 2+xPaQuh5tFvuuXiMrzFyG+2OOxZ0xr3gPMJIwGBZ/oIhyzdvRSHkfV7SeRVDaj0mB7b/s3Gl mK//6dhVf4pPu9+q8SFdoxz6cRz31cWqPz5QmkodwvWm8I4a3cXWEPVXZzol5Zoxzzv13aQ6z CQOsGcJWKkkGxi2GlW3u0hWm6/MnhKn8bhLIyZNKxK2lGwlO2IxQFuwf4fIESz3bLNKjGVrHh gJOi47IUCGr1HA= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Am Sun, Oct 17, 2021 at 12:48:40AM +0200 schrieb Karsten Hilbert: > > https://www.psycopg.org/psycopg3/docs/basic/transactions.html > > I am sorry to say this but this concept: > > This way we don=E2=80=99t have to remember to call neither > close() nor commit() and the database operation have > actually a persistent effect. > > seems fundamentally flawed to me in terms of databases. > Actually changing the content of a database should be a > conscious decision by program(mer) logic. I could, perhaps, agree with the *transaction* context manager being default-commit because: - after the context block the transaction has gone away - hence what happens inside either failed (auto-rollback) - or is to be committed Not so for the *connection* context manager. Best, Karsten =2D- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B