Visitar URL original
sqlite3 docs: extract row factory examples into row factory howto · Issue #96168 · python/cpython · GitHub
Skip to content

sqlite3 docs: extract row factory examples into row factory howto #96168

Description

@erlend-aasland

There are several row factory examples scattered around the sqlite3 docs. Most of them in various places in the reference. Suggesting to extract them and create a row factory How-to Guide, in order to clean up the reference and reduce duplication of information.

Activity

  1. erlend-aasland commented on Aug 22, 2022

    @erlend-aasland
    ContributorAuthor
  2. CAM-Gerlach commented on Aug 23, 2022

    @CAM-Gerlach
    Member

    Seems reasonable to me—short-ish examples are reasonable for a reference, but advice like

    If returning a tuple doesn’t suffice and you want name-based access to columns, you should consider setting row_factory to the highly optimized sqlite3.Row type. Row provides both index-based and case-insensitive name-based access to columns with almost no memory overhead. It will probably be better than your own custom dictionary-based approach or even a db_row based solution.

    is much more appropriate in a how-to, or perhaps actually an explanation (but there isn't really enough meat for that, and a how-to is certainly closer than a reference here)

  3. erlend-aasland commented on Aug 31, 2022

    @erlend-aasland
    ContributorAuthor

    As a first step, I suggest to improve the dict-factory example by:

    • modernising the code; we can use a dict comprehension
    • using a doctest, so the expected output is visible
    • SELECTing a row with multiple columns, so the effect of the dict factory becomes clearer
  4. added a commit that references this issue on Aug 31, 2022
  5. added 2 commits that reference this issue on Sep 1, 2022
  6. added a commit that references this issue on Sep 1, 2022
  7. added 2 commits that reference this issue on Sep 1, 2022
  8. added 4 commits that reference this issue on Nov 15, 2022
  9. added a commit that references this issue on Nov 25, 2022
  10. added 4 commits that reference this issue on Nov 25, 2022
  11. Repository owner moved this from TODO: Docs to Done in sqlite3 issueson Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions