Re: Adding Connection.autocommit as standard extension to DB-API 2.0 (PEP 249)
"Mike Bayer" <[email protected]> Mon, 14 Nov 2022 09:14:19 -0500
| Newsgroups | gmane.comp.python.db |
|---|---|
| Message-ID | <[email protected]> |
--===============0378701707028246349== Content-Type: multipart/alternative; boundary=6525d2f031f942c69ed945587dc33715 --6525d2f031f942c69ed945587dc33715 Content-Type: text/plain LGTM thanks! On Mon, Nov 14, 2022, at 8:23 AM, Marc-Andre Lemburg wrote: > Here's the updated wording for the addition, which should cover > everything we have discussed: > > """ > Connection.autocommit > > Attribute to query and set the autocommit mode of the connection. > > Returns True if the connection is operating in autocommit (non- > transactional) mode. Returns False is the connection is operating in > manual commit (transactional) mode. > > Setting the attribute to True or False adjusts the connection's mode > accordingly. > > Changing the setting from True to False (disabling autocommit) will > have the database leave autocommit mode and starts a new transaction. > Changing from False to True (enabling autocommit) has database > dependent semantics with respect to how pending transactions are > handled [1]. > > Deprecation notice: Even though several database modules implement > both the read and write nature of this attribute, setting the > autocommit mode by writing to the attribute is deprecated, since this > may result in I/O and related exceptions, making it difficult to > implement in an async context [2]. > > [1] Many database modules implementing the autocommit attribute will > automatically commit any pending transaction and then enter autocommit > mode. > > [2] For DB-API 3.0, we are going to introduce a new method > .setautocommit(value), which will allow setting the autocommit mode, and > make .autocommit a read-only attribute. Additionally, we are considering > to add a new standard keyword parameter autocommit to the Connection > constructor. Modules authors are encouraged to add these changes in > preparation for this change. > """ > > Please let me know whether I forgot anything. I'll prepare the PR > for PEP 249 later this week. > > Thanks, > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Experts (#1, Nov 14 2022) > >>> Python Projects, Coaching and Support ... https://www.egenix.com/ > >>> Python Product Development ... https://consulting.egenix.com/ > ________________________________________________________________________ > > ::: We implement business ideas - efficiently in both time and costs ::: > > eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 > D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg > Registered at Amtsgericht Duesseldorf: HRB 46611 > https://www.egenix.com/company/contact/ > https://www.malemburg.com/ > > _______________________________________________ > DB-SIG maillist - [email protected] > https://mail.python.org/mailman/listinfo/db-sig > --6525d2f031f942c69ed945587dc33715 Content-Type: text/html Content-Transfer-Encoding: quoted-printable <!DOCTYPE html><html><head><title></title><style type=3D"text/css">p.Mso= Normal,p.MsoNoSpacing{margin:0}</style></head><body><div>LGTM thanks!<br= ></div><div><br></div><div>On Mon, Nov 14, 2022, at 8:23 AM, Marc-Andre = Lemburg wrote:<br></div><blockquote type=3D"cite" id=3D"qt" style=3D""><= div>Here's the updated wording for the addition, which should cover<br><= /div><div>everything we have discussed:<br></div><div><br></div><div>"""= <br></div><div>Connection.autocommit<br></div><div><br></div><div> = Attribute to query and set the autocommit mode of the connection.= <br></div><div><br></div><div> Returns True if the connectio= n is operating in autocommit (non-<br></div><div> transactio= nal) mode. Returns False is the connection is operating in<br></div><div= > manual commit (transactional) mode.<br></div><div><br></di= v><div> Setting the attribute to True or False adjusts the c= onnection's mode<br></div><div> accordingly.<br></div><div><= br></div><div> Changing the setting from True to False (disa= bling autocommit) will<br></div><div> have the database leav= e autocommit mode and starts a new transaction.<br></div><div> &nbs= p; Changing from False to True (enabling autocommit) has database<br></d= iv><div> dependent semantics with respect to how pending tra= nsactions are<br></div><div> handled [1].<br></div><div><br>= </div><div> Deprecation notice: Even though several database= modules implement<br></div><div> both the read and write na= ture of this attribute, setting the<br></div><div> autocommi= t mode by writing to the attribute is deprecated, since this<br></div><d= iv> may result in I/O and related exceptions, making it diff= icult to<br></div><div> implement in an async context [2].<b= r></div><div><br></div><div>[1] Many database modules implementing the a= utocommit attribute will<br></div><div>automatically commit any pending = transaction and then enter autocommit<br></div><div>mode.<br></div><div>= <br></div><div>[2] For DB-API 3.0, we are going to introduce a new metho= d<br></div><div>.setautocommit(value), which will allow setting the auto= commit mode, and<br></div><div>make .autocommit a read-only attribute. A= dditionally, we are considering<br></div><div>to add a new standard keyw= ord parameter autocommit to the Connection<br></div><div>constructor. Mo= dules authors are encouraged to add these changes in<br></div><div>prepa= ration for this change.<br></div><div>"""<br></div><div><br></div><div>P= lease let me know whether I forgot anything. I'll prepare the PR<br></di= v><div>for PEP 249 later this week.<br></div><div><br></div><div>Thanks,= <br></div><div>-- <br></div><div>Marc-Andre Lemburg<br></div><div>e= Genix.com<br></div><div><br></div><div>Professional Python Services dire= ctly from the Experts (#1, Nov 14 2022)<br></div><div>>>> Pytho= n Projects, Coaching and Support ... <a href=3D"h= ttps://www.egenix.com/">https://www.egenix.com/</a><br></div><div>>&g= t;> Python Product Development ...  = ; <a href=3D"https://consulting.egenix.com/">https://consulti= ng.egenix.com/</a><br></div><div>_______________________________________= _________________________________<br></div><div><br></div><div>::: We im= plement business ideas - efficiently in both time and costs :::<br></div= ><div><br></div><div> eGenix.com Software, Skills and = Services GmbH Pastor-Loeh-Str.48<br></div><div> &= nbsp; D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg<br= ></div><div> = Registered at Amtsgericht Duesseldorf: HRB 46611<br></div><div>&n= bsp; &n= bsp; <a href=3D"https://www.egenix.com/company/contact/= ">https://www.egenix.com/company/contact/</a><br></div><div> = = <a href=3D"https://www.m= alemburg.com/">https://www.malemburg.com/</a><br></div><div><br></div><d= iv>_______________________________________________<br></div><div>DB-SIG = maillist - <a href=3D"mailto:[email protected]">DB-SIG@= python.org</a><br></div><div><a href=3D"https://mail.python.org/mailman/= listinfo/db-sig">https://mail.python.org/mailman/listinfo/db-sig</a><br>= </div><div><br></div></blockquote></body></html> --6525d2f031f942c69ed945587dc33715-- --===============0378701707028246349== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ DB-SIG maillist - [email protected] https://mail.python.org/mailman/listinfo/db-sig --===============0378701707028246349==--