Re: set autocommit only for select statements

From: Mladen Gogala <gogala(dot)mladen(at)gmail(dot)com>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: set autocommit only for select statements
Date: 2022-04-12 11:55:03
Message-ID: d557623b-5941-637d-9cd3-83e02285cf8f@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 4/12/22 05:01, Michel SALAIS wrote:
> What you write about psql sending a COMMIT statement after each statement is wrong. It may be true for other database systems.
>
> PostgreSQL as a server commits each statement automatically unless the client has started a transaction with BEGIN or START TRANSACTION statements.
>
> This can be proved easily by not using psql as a client, but some programming language.
>
> Regards,
>
> Holger

RDBMS, in order to be ACID compliant, deals with transactions, not with
single statements. It is the client who starts transaction, not the
database. It is also the client who sends commit. And yes, I am also
using Python which allows me to set autocommit property:

ttps://www.psycopg.org/docs/connection.html#connection.autocommit

If I set autocommit connection property to True, each cursor.execute
will send a commit. Autocommit cannot be set or disabled on the database
level because the database deals with transactions. The point where the
transaction is started and finished is the client. That is so for MySQL,
that is so for Oracle and that is so for Postgres.BTW, speaking of
Python, has anybody here tried Psycopg3? I know it was released but I am
not sure whether it's stable enough to use in production?

--
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Mladen Gogala 2022-04-12 12:00:35 Re: set autocommit only for select statements
Previous Message Michel SALAIS 2022-04-12 09:01:13 RE: set autocommit only for select statements