GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-96168: Add sqlite3 row factory how-to by erlend-aasland · Pull Request #99507 · python/cpython

Conversation

@erlend-aasland

@erlend-aasland erlend-aasland commented Nov 15, 2022 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: sqlite3 docs: extract row factory examples into row factory howto #96168

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@erlend-aasland
erlend-aasland requested a review from berkerpeksag as a code owner November 15, 2022 11:43
@erlend-aasland erlend-aasland added needs backport to 3.11 only security fixes needs backport to 3.10 skip news labels Nov 15, 2022
@erlend-aasland
erlend-aasland requested review from CAM-Gerlach and ezio-melotti November 15, 2022 11:43
@bedevere-bot bedevere-bot added awaiting core review docs Documentation in the Doc dir labels Nov 15, 2022
@bedevere-bot bedevere-bot mentioned this pull request Nov 15, 2022
sqlite3 docs: extract row factory examples into row factory howto #96168
Closed
@erlend-aasland
erlend-aasland force-pushed the sqlite-docs/row-factory-how-to branch 2 times, most recently from 7f95848 to dc774c6 Compare November 15, 2022 11:48
@erlend-aasland
pythongh-96168: Add sqlite3 row factory how-to
e985bab
@erlend-aasland
erlend-aasland force-pushed the sqlite-docs/row-factory-how-to branch from dc774c6 to e985bab Compare November 15, 2022 11:49
@erlend-aasland
Suggest reading the row factory how-to at the end of the tutorial
15d4b4e
erlend-aasland
erlend-aasland commented Nov 15, 2022
View reviewed changes
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland erlend-aasland mentioned this pull request Nov 15, 2022
namedtuple row factory for sqlite3 #57508
Closed
erlend-aasland added 3 commits November 15, 2022 13:00
@erlend-aasland
Fix named tuple example usage
f5f24b4
@erlend-aasland
Fix _fields helper
85c34bc
@erlend-aasland
Fix expected output in namedtuple row factory doctest
0e7ea3b
erlend-aasland
erlend-aasland commented Nov 15, 2022
View reviewed changes
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland
erlend-aasland commented Nov 15, 2022
View reviewed changes
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland
erlend-aasland commented Nov 15, 2022
View reviewed changes
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

merwok
merwok reviewed Nov 15, 2022
View reviewed changes
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

merwok
merwok reviewed Nov 15, 2022
View reviewed changes
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

CAM-Gerlach
CAM-Gerlach reviewed Nov 16, 2022
View reviewed changes

@CAM-Gerlach CAM-Gerlach left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @erlend-aasland .

Overall, I found the examples helpful, and a good balance between concise and detailed. However, maybe this is just me, but to me the section did appear pretty heavy on examples, but without as much explicit focus on solving specific user problems, as would be appropriate for a how-to. In that sense, it almost feels more like a tutorial, having readers learn using row factories by example, as opposed to telling them how to solve specific problems using row factories.

@ezio-melotti , what do you think?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland

erlend-aasland commented Nov 16, 2022

Copy link
Copy Markdown
Contributor Author

However, maybe this is just me, but to me the section did appear pretty heavy on examples, but without as much explicit focus on solving specific user problems, as would be appropriate for a how-to.

Yeah, maybe... but How To's are recipes. How can I create a foo row factory? How do I use a bar row factory? How do I use the sqlite3.Row row factory? I don't think it matters much that it is example heavy. IMO it is too thin for a tutorial, and definitely too thin for an explanation.

merwok reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland
Address reviews
413dc24
@erlend-aasland

erlend-aasland commented Nov 16, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Ouch, it just occurred to me that the Cursor also has a row_factory attribute, with the following problems:

  • it is not documented (easily fixed; we can do that in this PR done in this PR)
  • it is copied from the connection in Cursor.__init__, so changing the connection row factory does not affect the row factories of the cursors belonging to that connection; vice versa

So, more prose coming up.

>>> import sqlite3
>>> cx = sqlite3.connect(":memory:")
>>> cx.row_factory = sqlite3.Row
>>> cu = cx.cursor()
>>> cx.row_factory = None
>>> cu.row_factory == cx.row_factory
False
>>> cu.connection.row_factory == cx.row_factory
True
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland
Document Cursor.row_factory; tweak some sentences
ab98877
@erlend-aasland
erlend-aasland requested a review from CAM-Gerlach November 17, 2022 08:38
@erlend-aasland
Reword reference and remove example from ab98877
d12f559
@erlend-aasland

erlend-aasland commented Nov 22, 2022

Copy link
Copy Markdown
Contributor Author

@CAM-Gerlach: I've reworded the reference, hopefully to the better; IMO the current version reflects the difference between the two row factory attributes more clearly. I also removed the example from ab98877; IMO it is superfluous with the now (hopefully) improved reference. Looking forward to your comments.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

CAM-Gerlach
CAM-Gerlach reviewed Nov 23, 2022
View reviewed changes

@CAM-Gerlach CAM-Gerlach left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed looking pretty good, thanks. Follow-up suggestions are basically just textual tweaks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland
Address most of CAM's latest review
a277467
erlend-aasland
erlend-aasland commented Nov 23, 2022
View reviewed changes
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland
Address review
cd12c6b
@erlend-aasland
erlend-aasland requested review from CAM-Gerlach and merwok November 23, 2022 20:30
ezio-melotti
ezio-melotti reviewed Nov 23, 2022
View reviewed changes
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

CAM-Gerlach
CAM-Gerlach reviewed Nov 24, 2022
View reviewed changes

@CAM-Gerlach CAM-Gerlach left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good to me now, personally, Just a couple minor suggestions and followups to others' comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@merwok
merwok removed their request for review November 24, 2022 06:42
@erlend-aasland
Address reviews
86a2c43
CAM-Gerlach
CAM-Gerlach reviewed Nov 25, 2022
View reviewed changes

@CAM-Gerlach CAM-Gerlach left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment cleaning up my own mess, otherwise LGTM from my side, thanks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland reacted with hooray emoji
All reactions
  • 🎉 1 reaction
Comment thread Doc/library/sqlite3.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland added 2 commits November 25, 2022 09:40
@erlend-aasland
Split dict row factory example in two
f9fa2ee
@erlend-aasland
Missed one
6f50503
@erlend-aasland

erlend-aasland commented Nov 25, 2022

Copy link
Copy Markdown
Contributor Author

Thanks again y'all for improving this part of the docs. I'm going to land this later today. A lot of back and forth, but IMO totally worth it.

CAM-Gerlach reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland
erlend-aasland merged commit 8749121 into python:main Nov 25, 2022
@miss-islington

miss-islington commented Nov 25, 2022

Copy link
Copy Markdown
Contributor

Thanks @erlend-aasland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting core review label Nov 25, 2022
@erlend-aasland
erlend-aasland deleted the sqlite-docs/row-factory-how-to branch November 25, 2022 13:07
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 25, 2022
@erlend-aasland @CAM-Gerlach
@ezio-melotti @miss-islington
pythongh-96168: Add sqlite3 row factory how-to (pythonGH-99507)
8444dcf
(cherry picked from commit 8749121)

Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
Co-authored-by: Ezio Melotti <[email protected]>
@bedevere-bot

bedevere-bot commented Nov 25, 2022

Copy link
Copy Markdown

GH-99778 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Nov 25, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 25, 2022
@erlend-aasland @CAM-Gerlach
@ezio-melotti @miss-islington
pythongh-96168: Add sqlite3 row factory how-to (pythonGH-99507)
0582b95
(cherry picked from commit 8749121)

Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
Co-authored-by: Ezio Melotti <[email protected]>
@bedevere-bot

bedevere-bot commented Nov 25, 2022

Copy link
Copy Markdown

GH-99779 is a backport of this pull request to the 3.10 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 label Nov 25, 2022
miss-islington added a commit that referenced this pull request Nov 25, 2022
@miss-islington @erlend-aasland
@CAM-Gerlach @ezio-melotti
gh-96168: Add sqlite3 row factory how-to (GH-99507)
5b74084
(cherry picked from commit 8749121)

Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
Co-authored-by: Ezio Melotti <[email protected]>
miss-islington added a commit that referenced this pull request Nov 25, 2022
@miss-islington @erlend-aasland
@CAM-Gerlach @ezio-melotti
gh-96168: Add sqlite3 row factory how-to (GH-99507)
aabe831
(cherry picked from commit 8749121)

Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
Co-authored-by: Ezio Melotti <[email protected]>
@CAM-Gerlach CAM-Gerlach mentioned this pull request Nov 30, 2022
gh-99824: Document that sqlite3.connect implicitly open a transaction if autocommit=False #99825
Merged
@erlend-aasland erlend-aasland mentioned this pull request Oct 10, 2023
Bad row factory example in the sqlite docs #110643
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@merwok merwok merwok left review comments
@CAM-Gerlach CAM-Gerlach CAM-Gerlach left review comments
@ezio-melotti ezio-melotti ezio-melotti left review comments
@berkerpeksag berkerpeksag Awaiting requested review from berkerpeksag

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@erlend-aasland @miss-islington @bedevere-bot @merwok @CAM-Gerlach @ezio-melotti
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.