Re: set autocommit only for select statements - Mailing list pgsql-admin

From Mladen Gogala
Subject Re: set autocommit only for select statements
Date
Msg-id d557623b-5941-637d-9cd3-83e02285cf8f@gmail.com
Whole thread Raw
In response to RE: set autocommit only for select statements  ("Michel SALAIS" <msalais@msym.fr>)
List 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

pgsql-admin by date:

Previous
From: "Michel SALAIS"
Date:
Subject: RE: set autocommit only for select statements
Next
From: Mladen Gogala
Date:
Subject: Re: set autocommit only for select statements