Python Forum
Is there a standard for autocommit In PEP 249
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a standard for autocommit In PEP 249
#6
Almost all databases support auto-commit,just that is off bye default in most cases for Python,as mention in 249.
PEP 249 Wrote:Note that if the database supports an auto-commit feature, this must be initially off. An interface method may be provided to turn it back on.
There is a reason behind this from mailing list,long time ago:
Quote:Auto commit is a bad thing and a pretty evil invention of ODBC.
While it does make writing ODBC drivers simpler (ones which don't support transactions that is),
it is potentially dangerous at times, e.g. take a crashing program: there is no way to recover from errors because the database has no way of knowing which data is valid and which is not.
No commercial application handling "mission critical" (I love that term ;-) data would ever want to run in auto-commit mode.
Quote:ANY serious application MUST manage its own transactions, as otherwise you can't ever hope to control failure modes.
Python developers took this sort of information into consideration and decided the benefit of having auto-commit off by default (easier error handling and reversing).

That said it's very easy to turn on in almost all cases.
# PostgreSQL
conn.set_session(readonly=True, autocommit=True)

# For Flask-SQLAlchemy(what i use most)
db = SQLAlchemy(app, session_options={'autocommit': True})
SQLAlchemy Python biggest ORM,dos implements it's own auto-commit.
Understanding Autocommit
Quote:SQLAlchemy implements its own “autocommit” feature which works completely consistently across all backends
Reply


Messages In This Thread
RE: Is there a standard for autocommit In PEP 249 - by snippsat - Feb-06-2019, 08:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How psycopg2 autocommit works ? johntay 3 10,648 Oct-08-2021, 11:22 AM
Last Post: Larz60+
  Winsorized Mean and Standard Deviation Wheeliam 0 1,845 Jul-11-2020, 05:27 PM
Last Post: Wheeliam
  standard library modules chpyel 4 2,856 May-10-2020, 02:58 PM
Last Post: snippsat
  Graphics and standard deviation rocioaraneda 3 2,750 Jan-09-2019, 10:53 PM
Last Post: micseydel
  standard data types rombertus 3 66,229 Dec-23-2018, 08:52 PM
Last Post: rombertus
  Standard library code BerryK 2 4,048 Apr-29-2017, 10:32 PM
Last Post: Larz60+
  what is my standard in python currently? hsunteik 3 3,781 Jan-19-2017, 12:37 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020