Sqlite3 module: implement Connection.changes

The sqlite3 module already exposes sqlite3_total_changes() as Connection.total_changes. It would be really nice if it also exposed sqlite3_changes() as Connection.changes.

It is possible to get the value by using conn.execute('SELECT changes()').fetchone()[0] but that’s both cumbersome and inefficient.

Seems reasonable to me. I would probably use sqlite3_changes64 when available instead to not truncate in a big query case.

I’d be open to filing a PR for it too since it looks fun to play with a bit if no objections.

Have a quick check of the issue tracker Issues · python/cpython · GitHub to see if anyone else has asked about this, too.

Don’t see any other asks about it on the tracker

Honestly, it might be quite disappointing to play with: I imagine the code would be a simple cut-and-paste from Connection.total_changes. :slightly_smiling_face:

Was a little fun still :stuck_out_tongue: gh-163106: Add sqlite3.Connection.changes by csm10495 · Pull Request #163108 · python/cpython · GitHub

1 Like