Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8b068c4

Browse files
miss-islingtonErlend Egeberg Aasland
and
Erlend Egeberg Aasland
authored
gh-93925: Improve clarity of sqlite3 commit/rollback, and close docs (GH-93926)
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>(cherry picked from commit6446592)Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
1 parent1073184 commit8b068c4

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

‎Doc/library/sqlite3.rst‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -413,21 +413,20 @@ Connection Objects
413413

414414
..method::commit()
415415

416-
This method commits the current transaction. If you don't call this method,
417-
anything you did since the last call to ``commit()`` is not visible from
418-
other database connections. If you wonder why you don't see the data you've
419-
written to the database, please check you didn't forget to call this method.
416+
Commit any pending transaction to the database.
417+
If there is no open transaction, this method is a no-op.
420418

421419
..method::rollback()
422420

423-
This method rollsbackany changesto thedatabase since the last call to
424-
:meth:`commit`.
421+
Rollback to thestart of any pending transaction.
422+
If there is no open transaction, this method is a no-op.
425423

426424
..method::close()
427425

428-
This closes the database connection. Note that this does not automatically
429-
call:meth:`commit`. If you just close your database connection without
430-
calling:meth:`commit` first, your changes will be lost!
426+
Close the database connection.
427+
Any pending transaction is not committed implicitly;
428+
make sure to:meth:`commit` before closing
429+
to avoid losing pending changes.
431430

432431
..method::execute(sql[, parameters])
433432

‎Modules/_sqlite/clinic/connection.c.h‎

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Modules/_sqlite/connection.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,14 @@ blobopen_impl(pysqlite_Connection *self, const char *table, const char *col,
470470
/*[clinic input]
471471
_sqlite3.Connection.close as pysqlite_connection_close
472472
473-
Closes the connection.
473+
Close the database connection.
474+
475+
Any pending transaction is not committed implicitly.
474476
[clinic start generated code]*/
475477

476478
staticPyObject*
477479
pysqlite_connection_close_impl(pysqlite_Connection*self)
478-
/*[clinic end generated code: output=a546a0da212c9b97 input=3d58064bbffaa3d3]*/
480+
/*[clinic end generated code: output=a546a0da212c9b97 input=b3ed5b74f6fefc06]*/
479481
{
480482
if (!pysqlite_check_thread(self)) {
481483
returnNULL;
@@ -522,12 +524,14 @@ int pysqlite_check_connection(pysqlite_Connection* con)
522524
/*[clinic input]
523525
_sqlite3.Connection.commit as pysqlite_connection_commit
524526
525-
Commit the current transaction.
527+
Commit any pending transaction to the database.
528+
529+
If there is no open transaction, this method is a no-op.
526530
[clinic start generated code]*/
527531

528532
staticPyObject*
529533
pysqlite_connection_commit_impl(pysqlite_Connection*self)
530-
/*[clinic end generated code: output=3da45579e89407f2 input=39c12c04dda276a8]*/
534+
/*[clinic end generated code: output=3da45579e89407f2 input=c8793c97c3446065]*/
531535
{
532536
if (!pysqlite_check_thread(self)|| !pysqlite_check_connection(self)) {
533537
returnNULL;
@@ -557,12 +561,14 @@ pysqlite_connection_commit_impl(pysqlite_Connection *self)
557561
/*[clinic input]
558562
_sqlite3.Connection.rollback as pysqlite_connection_rollback
559563
560-
Roll back the current transaction.
564+
Roll back to the start of any pending transaction.
565+
566+
If there is no open transaction, this method is a no-op.
561567
[clinic start generated code]*/
562568

563569
staticPyObject*
564570
pysqlite_connection_rollback_impl(pysqlite_Connection*self)
565-
/*[clinic end generated code: output=b66fa0d43e7ef305 input=12d4e8d068942830]*/
571+
/*[clinic end generated code: output=b66fa0d43e7ef305 input=7f60a2f1076f16b3]*/
566572
{
567573
if (!pysqlite_check_thread(self)|| !pysqlite_check_connection(self)) {
568574
returnNULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp