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 — sqlite3: issue a warning if a sequence of params are used with named placeholders in queries · Issue #101693 · python/cpython

sqlite3: issue a warning if a sequence of params are used with named placeholders in queries #101693

New issue
Copy link
New issue
Copy link
Closed
Closed
sqlite3: issue a warning if a sequence of params are used with named placeholders in queries#101693
Copy link
Assignees
erlend-aasland
Labels
topic-sqlite3type-featureA feature request or enhancementA feature request or enhancement

Description

@erlend-aasland
erlend-aasland
opened on Feb 8, 2023
Issue body actions

(See Discourse topic.)

Per now, it is possible to supply a sequence of params to queries with named placeholders:

>>> cx.execute("select :name", [42]).fetchall()
[(42,)]
>>> cx.execute("select :other", [42]).fetchall()
[(42,)]

This may result in unexpected results if a user misuse the sqlite3 module and use PEP-249 style numeric placeholders:

>>> cx.execute("select :1", ("first",)).fetchall()
[('first',)]
>>> cx.execute("select :1, :2", ("first", "second")).fetchall()
[('first', 'second')]
>>> cx.execute("select :2, :1", ("first", "second")).fetchall()  # Unexpected result follows
[('first', 'second')]

PEP-249 style numeric placeholders are not supported by sqlite3; it only supports PEP-249 style named placeholders and PEP-249 style qmark placeholders, so the placeholders in the above example are interpreted as named, not numeric, placeholders.

Based on the discussion in the above linked Discourse topic, I propose to now issue a deprecation warning if sequences are used with named placeholders. The deprecation warning should inform that from Python 3.14 and onward, sqlite3.ProgrammingError will be raised instead.

Linked PRs

  • gh-101693: In sqlite3, deprecate using named placeholders with parameters supplied as a sequence #101698

Activity

  1. erlend-aasland
    added this to sqlite3 issueson Jan 11, 2023
  2. erlend-aasland
    converted this from a draft issue on Feb 8, 2023
  3. erlend-aasland
    self-assigned this
    on Feb 8, 2023
  4. erlend-aasland
    added
    type-featureA feature request or enhancementA feature request or enhancement
    topic-sqlite3
    on Feb 8, 2023
  5. erlend-aasland
    moved this from TODO: Feature to In Progress in sqlite3 issueson Feb 8, 2023
  6. erlend-aasland
    added a commit that references this issue on Feb 15, 2023

    gh-101693: In sqlite3, deprecate using named placeholders with parame…

    8a2b7ee
  7. erlend-aasland
    closed this as completedon Feb 15, 2023
  8. github-project-automation
    moved this from In Progress to Done in sqlite3 issueson Feb 15, 2023
  9. erlend-aasland
    added 2 commits that reference this issue on May 10, 2024

    pythongh-118928: sqlite3: disallow sequences of params with named pla…

    b66f04a

    gh-118928: sqlite3: disallow sequences of params with named placehold…

    d8e0e00
  10. estyxx
    added a commit that references this issue on Jul 17, 2024

    pythongh-118928: sqlite3: disallow sequences of params with named pla…

    e5f4338
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @erlend-aasland
    erlend-aasland

Labels

topic-sqlite3type-featureA feature request or enhancementA feature request or enhancement

Projects

  • sqlite3 issues
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

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.